Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Walk a directory tree in node.js

branch: master

1.1.1

latest commit 76f0808ce0
James Halliday authored
Octocat-spinner-32 example revamped the readme September 14, 2013
Octocat-spinner-32 test failing empty test February 26, 2014
Octocat-spinner-32 .travis.yml travis badge September 14, 2013
Octocat-spinner-32 LICENSE revamped the readme September 14, 2013
Octocat-spinner-32 index.js fix problem with walk for nested empty directories February 26, 2014
Octocat-spinner-32 package.json 1.1.1 February 26, 2014
Octocat-spinner-32 readme.markdown document finder.stop() September 14, 2013
readme.markdown

findit

Recursively walk directory trees. Think /usr/bin/find.

build status

example

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);
});

methods

var find = require('findit')

var finder = find(basedir, opts)

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".

finder.stop()

Stop the traversal. A "stop" event will fire and then no more events will fire.

events

finder.on('path', function (file, stat) {})

For each file, directory, and symlink file, this event fires.

finder.on('file', function (file, stat) {})

For each file, this event fires.

finder.on('directory', function (dir, stat, stop) {})

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.

finder.on('link', function (file, stat) {})

For each symlink, this event fires.

finder.on('readlink', function (src, dst) {})

Every time a symlink is read when opts.followSymlinks is on, this event fires.

finder.on('end', function () {})

When the recursive walk is complete unless finder.stop() was called, this event fires.

finder.on('stop', function () {})

When finder.stop() is called, this event fires.

install

With npm do:

npm install findit

license

MIT

Something went wrong with that request. Please try again.