Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
handle errors to fs.readdir()
Browse files Browse the repository at this point in the history
  • Loading branch information
tmont committed Jan 18, 2013
1 parent c4753a4 commit 9dbd751
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/wrench.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ exports.readdirRecursive = function(baseDir, fn) {

waitCount++;
fs.readdir(curDir, function(e, curFiles) {
if (e) {
fn(e);
return;
}
waitCount--;

curFiles = curFiles.map(prependcurDir);
Expand Down
9 changes: 9 additions & 0 deletions tests/readdir.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ module.exports = testCase({
checkResult(test, allFiles);
}
});
},

test_readdirRecursiveWithNonExistentDirectory: function(test) {
wrench.readdirRecursive('', function (e, files) {
test.ok(e);
test.equal(e.code, 'ENOENT');
test.equal(files, null);
test.done();
});
}
});

Expand Down

0 comments on commit 9dbd751

Please sign in to comment.