Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit b96b0ce

Browse files
authored
Fix download async.series calls (#199)
- Use fs.stat instead of fs.exists because the latter is deprecated - Properly pass errors along. `fs.exists()` had an odd signature that was missing the typical Node.js `error` argument as its first position, and instead always called the callback with a single boolean. When the `async` package was updated to 3.x, this broke this functionality (and the tests), because it didn’t handle this “interpret a boolean as an error” hack well. Fix this by passing proper error objects to the callback.
1 parent 3a5859a commit b96b0ce

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/download.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ module.exports = function(model, done) {
4949
derived: true
5050
}));
5151
async.series([
52-
fs.exists.bind(null, model.bin_directory),
52+
function(cb) {
53+
fs.stat(model.bin_directory, function(err) {
54+
if (err) {
55+
cb();
56+
} else {
57+
cb(new Error('already exists'));
58+
}
59+
});
60+
},
5361
download.bind(null, model)
54-
], function(err) {
55-
if (err === true) {
62+
], function(err, results) {
63+
if (err && err.message === 'already exists') {
5664
debug('already have artifact at `%s`', model.bin_directory);
5765
return done();
5866
}

0 commit comments

Comments
 (0)