diff --git a/README.md b/README.md index bba5c6e..d49e04c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ The Synchronous version still uses callbacks, so it is safe to use with other As options = { followLinks: false, + // filters: ["Temp", "_Temp"] // directories with these + // keys will be skipped }; walker = walk.walk("/tmp", options); diff --git a/lib/walk.js b/lib/walk.js index 5209198..e80ebf6 100644 --- a/lib/walk.js +++ b/lib/walk.js @@ -35,6 +35,7 @@ me._wq = []; me._wqueue = [me._wq]; me._wcurpath = undefined; + me._wfilters = options.filters; me._wfirstrun = true; me._wcurpath = pathname; @@ -175,10 +176,23 @@ , me = this ; - try { - files = fs.readdirSync(me._wcurpath); - } catch(e) { - err = e; + // Stop directories that contain filter keywords + // from continuing through the walk process + if (me._wfilters != undefined) { + var shouldExclude = false; + for (var iFilter=0; iFilter