readdirSyncRecursive: add a filter argument

filter is an optional filter function that will be applied on the records of
each sub-directory to keep only the records you need. Avoiding redundencies
is critical for big folders trees
This commit is contained in:
Daniel Chcouri 2014-05-13 11:08:54 +03:00
parent 13f486d867
commit cd1f107279
3 changed files with 30 additions and 2 deletions

View file

@ -30,6 +30,16 @@ module.exports = testCase({
checkResult(test, files);
},
test_readdirSyncRecursive_filter: function(test) {
var dir = path.join(__dirname, 'readdir');
var txt_files = wrench.readdirSyncRecursive(dir, function (x) {return /\.txt$/.test(x);});
test.deepEqual(txt_files, ['bar.txt', path.join('foo', 'lorem.txt')]);
test.done();
},
test_readdirRecursive: function(test) {
var dir = path.join(__dirname, 'readdir');