Yet another library for watching FS trees. Includes a JSON-on-stdout command-line tool and {filePreexisted,allPreexistingFilesReported} events. yet another NodeJS FS-watching library. If it happens to suit your needs better than the others, enjoy!

The current implementation maintains a ring of paths (both files and dirs), and stats the next one every (--sample-rate=) ms.

More efficient implementations will be added eventually, including inotify (for Linux) and FSEvents (for Mac), with the appropriate one being compiled at (npm install)-time.

Your code won't notice the difference when that happens, but your battery life might.

npm install watch-tree
watch-tree [[relative_]path]
cd ~/repos/watch-tree; watch-tree '--ignore=/\.'

The watcher returned by .watchTree is a NodeJS EventEmitter instance.

watcher = require('watch-tree').watchTree(path, {'sample-rate': 5});
watcher.on('fileDeleted', function(path) {
    console.log("Quoth the walrus: Noooo, they're deleting mah " + path + "!");
Event Callback Arguments
filePreexisted path, stats
fileCreated path, stats
fileModified path, stats
fileDeleted path

...where stats is a NodeJS fs.Stats instance.

# Install
git clone; cd node-watch-tree
npm link


coffee -cwlo lib src


cake build && cake test