From 60ddf2a5034420b8cec96d668630c1b60673be8a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 5 Jul 2013 16:41:46 -0700 Subject: [PATCH] made filter to work by regex (untested) --- .jshintrc | 3 +-- lib/walk.js | 61 ++++++++++++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/.jshintrc b/.jshintrc index 81d5568..406049c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,5 +1,4 @@ -{ "es5": true -, "node": true +{ "node": true , "browser": true , "jquery": true diff --git a/lib/walk.js b/lib/walk.js index 7ce9794..de36921 100644 --- a/lib/walk.js +++ b/lib/walk.js @@ -37,7 +37,7 @@ me._wq = []; me._wqueue = [me._wq]; me._wcurpath = undefined; - me._wfilters = options.filters; + me._wfilters = options.filters || []; me._wfirstrun = true; me._wcurpath = pathname; @@ -185,30 +185,32 @@ me._wReadFiles(); }); }; + Walker.prototype._wFilter = function () { + var me = this + , exclude + ; + + // Stop directories that contain filter keywords + // from continuing through the walk process + exclude = me._wfilters.some(function (filter) { + if (me._wcurpath.match(filter)) { + return true; + } + }); + + return exclude; + }; Walker.prototype._wWalkSync = function () { - console.log('walkSync'); + //console.log('walkSync'); var err , files , me = this ; - // Stop directories that contain filter keywords - // from continuing through the walk process - if (me._wfilters != undefined) { - var shouldExclude = false; - for (var iFilter=0; iFilter