Recursively walk directory trees. Think /usr/bin/find
.
var finder = require('findit')(process.argv[2] || '.');
var path = require('path');
finder.on('directory', function (dir, stat, stop) {
var base = path.basename(dir);
if (base === '.git' || base === 'node_modules') stop()
else console.log(dir + '/')
});
finder.on('file', function (file, stat) {
console.log(file);
});
finder.on('link', function (link, stat) {
console.log(link);
});
var find = require('findit')
Return an event emitter finder
that performs a recursive walk starting at
basedir
.
If you set opts.followSymlinks
, symlinks will be followed. Otherwise, a
'link'
event will fire but symlinked directories will not be walked.
If basedir
is actually a non-directory regular file, findit emits a single
"file" event for it then emits "end".
Stop the traversal. A "stop"
event will fire and then no more events will
fire.
For each file, directory, and symlink file
, this event fires.
For each file, this event fires.
For each directory, this event fires with the path dir
.
Your callback may call stop()
on the first tick to tell findit to stop walking
the current directory.
For each symlink, this event fires.
Every time a symlink is read when opts.followSymlinks
is on, this event fires.
When the recursive walk is complete unless finder.stop()
was called, this
event fires.
When finder.stop()
is called, this event fires.
With npm do:
npm install findit
MIT