Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
- "6"
- "8"
before_install:
- npm i -g npm
6 changes: 2 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "5"
- nodejs_version: "6"
- nodejs_version: "8"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
6 changes: 0 additions & 6 deletions buster.js

This file was deleted.

60 changes: 34 additions & 26 deletions lib/multi-glob.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
var glob = require("glob");
var async = require("async");
var _ = require("lodash");

exports._glob = glob;

function uniq(xs) {
return xs.reduce((unique, x) => {
return unique.indexOf(x) < 0 ? unique.concat(x) : unique;
}, []);
}

function flatten(xs) {
return xs.reduce((flattened, x) => {
return flattened.concat(Array.isArray(x) ? flatten(x) : x);
}, []);
}

function array(arr) {
return Array.isArray(arr) ? arr : [arr];
}

function resolveGlobs(patterns, options) {
options = options || {};
return array(patterns).reduce(function (fns, pattern) {
fns.push(function (done) {
glob(pattern, options, function (err, matches) {
if (!err && options.strict && matches.length === 0) {
done(new Error("'" + pattern + "' matched no files"));
} else {
done(err, matches);
}
return Promise.all(
array(patterns).map(pattern => new Promise((resolve, reject) => {
exports._glob(pattern, options, (err, matches) => {
if (!err && options.strict && matches.length === 0) {
reject(new Error("'" + pattern + "' matched no files"));
} else if (err) {
reject(err);
} else {
resolve(matches);
}
});
});
return fns;
}, []);
}))
);
}

function processSingle(callback) {
return function (err, matches) {
callback(err, _.uniq(_.flatten(_.toArray(matches))));
};
}
exports.glob = function (patterns, options, cb) {
if (typeof options === "function") {
cb = options;
options = null;
}

module.exports = {
glob: function (patterns, options, cb) {
if (typeof options === "function") {
cb = options;
options = null;
}
async.parallel(resolveGlobs(patterns, options), processSingle(cb));
}
resolveGlobs(patterns, options)
.then(matches => cb(null, uniq(flatten(array(matches)))))
.catch(err => cb(err));
};
Loading