From 85e84a0a3f7d87c49271438f4ad10b2db52243ae Mon Sep 17 00:00:00 2001 From: ZECTBynmo Date: Sat, 20 Apr 2013 16:29:37 -0400 Subject: [PATCH] Change option name to 'filters' and implimented filtering for synchronous walking --- README.md | 4 ++-- lib/walk.js | 31 +++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 56d1285..d49e04c 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ The Synchronous version still uses callbacks, so it is safe to use with other As options = { followLinks: false, - // asyncFilters: ["Temp", "_Temp"] // directories with these - // keys will be skipped + // 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 8e34fd8..31aabca 100644 --- a/lib/walk.js +++ b/lib/walk.js @@ -35,7 +35,7 @@ me._wq = []; me._wqueue = [me._wq]; me._wcurpath = undefined; - me._wasyncFilters = options.asyncFilters; + me._wfilters = options.filters; me._wfirstrun = true; me._wcurpath = pathname; @@ -176,12 +176,27 @@ , 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