3 var path = require('path');
4 var helper = module.exports = {};
6 // Returns boolean whether filepath is dir terminated
7 helper.isDir = function isDir (dir) {
8 if (typeof dir !== 'string') {
11 return (dir.slice(-(path.sep.length)) === path.sep);
14 // Create a `key:[]` if doesnt exist on `obj` then push or concat the `val`
15 helper.objectPush = function objectPush (obj, key, val) {
16 if (obj[key] == null) {
19 if (Array.isArray(val)) {
20 obj[key] = obj[key].concat(val);
24 obj[key] = helper.unique(obj[key]);
28 // Ensures the dir is marked with path.sep
29 helper.markDir = function markDir (dir) {
30 if (typeof dir === 'string' &&
31 dir.slice(-(path.sep.length)) !== path.sep &&
38 // Changes path.sep to unix ones for testing
39 helper.unixifyPathSep = function unixifyPathSep (filepath) {
40 return (process.platform === 'win32') ? String(filepath).replace(/\\/g, '/') : filepath;
44 * Lo-Dash 1.0.1 <http://lodash.com/>
45 * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
46 * Based on Underscore.js 1.4.4 <http://underscorejs.org/>
47 * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
48 * Available under MIT license <http://lodash.com/license>
50 helper.unique = function unique () {
51 var array = Array.prototype.concat.apply(Array.prototype, arguments);
53 for (var i = 0; i < array.length; i++) {
54 if (result.indexOf(array[i]) === -1) {
55 result.push(array[i]);
62 * Copyright (c) 2010 Caolan McMahon
63 * Available under MIT license <https://raw.github.com/caolan/async/master/LICENSE>
65 helper.forEachSeries = function forEachSeries (arr, iterator, callback) {
66 if (!arr.length) { return callback(); }
68 var iterate = function () {
69 iterator(arr[completed], function (err) {
72 callback = function () {};
75 if (completed === arr.length) {