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
130 stars 22 forks source link

Add a way to stop the traversal of a branch #19

Closed wattsbn closed 9 years ago

wattsbn commented 9 years ago

It would be really nice if there was a way to stop the traversal of just a branch instead of the entire tree.

For example if you didn't want to process any files or subdirectories of 'foo'

emitter.on('directory', function(dir, stat, stop) {
    if (path.dirname(path) === 'foo') { stop(); }
    ...
});
soldair commented 9 years ago

i think so too. thats better than the ignore path's strategy

soldair commented 9 years ago

fixed in 0.0.9. added .ignore(path) to the emitter which can be called both in the path event listener and before.