soldair / node-walkdir

Walk a directory tree emitting events based on the contents. API compatable with node-findit. Walk a tree of any depth. Fast! Handles permission errors. Stoppable. windows support. Pull requests are awesome. watchers are appreciated.
MIT License
131 stars 22 forks source link

Exclude directories from search #9

Closed mikaa123 closed 9 years ago

mikaa123 commented 11 years ago

Hey there,

Any way to exclude directories (e.g. .git) in the actual version? Awesome module, btw.

Cheers, Michael

soldair commented 11 years ago

hey. not right now but as it can make it faster if it doesn't have to traverse directories you don't want i'm willing to accept a pull request / ideas on how it should work.

Up till now i have just ignored in the path listener unless its something i'm interested in.

i would use options.exclude and options.exclude could be ..

string the basename of the directory or file you want to exclude or an array of the above

if anyone is interested in general filtering one could add support for options.filter with this criteria

string p.indexOf(string) > -1 to find match regexp p.match(exp) to find match function !!options.exclude(p) to find match or an array of any of the above

as a compliment options.grep could be added to the opposite effect of options.filter

after usefulness the most important thing is to make sure that any of these don't decrease performance. If these features are useful to enough people i will add them. Either way pull requests are cool.

soldair commented 9 years ago

fixed in npm version 0.0.9