Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit 99ab7f3

Browse files
committed
Drop async dependency
1 parent 1a95582 commit 99ab7f3

4 files changed

Lines changed: 17 additions & 27 deletions

File tree

lib/multi-glob.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var glob = require("glob");
2-
var async = require("async");
32

43
exports._glob = glob;
54

@@ -21,30 +20,28 @@ function array(arr) {
2120

2221
function resolveGlobs(patterns, options) {
2322
options = options || {};
24-
return array(patterns).reduce(function (fns, pattern) {
25-
fns.push(function (done) {
26-
exports._glob(pattern, options, function (err, matches) {
27-
if (!err && options.strict && matches.length === 0) {
28-
done(new Error("'" + pattern + "' matched no files"));
29-
} else {
30-
done(err, matches);
31-
}
23+
return Promise.all(
24+
array(patterns).map(pattern => new Promise((resolve, reject) => {
25+
exports._glob(pattern, options, (err, matches) => {
26+
if (!err && options.strict && matches.length === 0) {
27+
reject(new Error("'" + pattern + "' matched no files"));
28+
} else if (err) {
29+
reject(err);
30+
} else {
31+
resolve(matches);
32+
}
3233
});
33-
});
34-
return fns;
35-
}, []);
36-
}
37-
38-
function processSingle(callback) {
39-
return function (err, matches) {
40-
callback(err, uniq(flatten(array(matches))));
41-
};
34+
}))
35+
);
4236
}
4337

4438
exports.glob = function (patterns, options, cb) {
4539
if (typeof options === "function") {
4640
cb = options;
4741
options = null;
4842
}
49-
async.parallel(resolveGlobs(patterns, options), processSingle(cb));
43+
44+
resolveGlobs(patterns, options)
45+
.then(matches => cb(null, uniq(flatten(array(matches)))))
46+
.catch(err => cb(err));
5047
};

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
"node": ">= 6"
3232
},
3333
"dependencies": {
34-
"glob": "5.x",
35-
"async": "1.x"
34+
"glob": "5.x"
3635
},
3736
"devDependencies": {
3837
"@sinonjs/referee-sinon": "^4.1.0",

test/multi-glob-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ describe("Multi-glob", function () {
4141
});
4242

4343
it("calls callback with result from glob", function (done) {
44-
var callback = sinon.spy();
4544
nodeGlobStub.yields(null, ["lib/buster.js"]);
4645

4746
multiGlob.glob("lib/buster.js", function (err, res) {

0 commit comments

Comments
 (0)