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:
parent
13f486d867
commit
cd1f107279
3 changed files with 30 additions and 2 deletions
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
Reference in a new issue