A directory watcher

npm install directory-watcher
1 downloads in the last day
5 downloads in the last week
18 downloads in the last month


A directory watcher that keeps an in memory list of the files in the directory, perfoming diffs on them when events arise from the underlying FSWatcher, which doesn't always reports back the files that are related to the event.

The API also provides "nicer" events using the EventEmitter API: "changed", "added", "deleted". (currently "changed" doesn't function properly when underlying watcher doesn't supply the filename)


    npm install directory-watcher

create a watcher using FSWatcher

var DirectoryWatcher = require('directory-watcher');

DirectoryWatcher.create('/path/to/somewhere', function(err, watcher) {
    watcher.once('changed', function(files) {
        console.log('will fire once');        

    watcher.on('deleted', function(files) {
        console.log('%s deleted', files);

    watcher.on('added', function(files) {
        console.log('%s added', files);

using without FSWatcher or with extental FSWatcher (untested)

var DirectoryWatcher = require('directory-watcher');

DirectoryWatcher.createEx('/path/to/somewhere', function(err, watcher) {
    var onFileEvent = watcher.listener();
    onFileEvent('rename', undefined);


var DirectoryWatcher = require('directory-watcher');
var fs = require('fs');

DirectoryWatcher.createEx('/path/to/somewhere', function(err, watcher) {, watcher.listener(), { persistent: false });

note that watcher.kill() will only clear the internal files cache in this instance

npm loves you