A watcher for NodeJS, that works well with large directories. It leverages the unix find
command for improved performance and reliability.
npm install large-watcher
var watcher = require('large-watcher');
var w = watcher('/Users/aaron/git/large-watcher', 1).start();
var log = console.log.bind(console);
w.on('change', log.bind(null, 'change'));
w.on('created', log.bind(null, 'created'));
w.on('deleted', log.bind(null, 'deleted'));
w.on('modified', log.bind(null, 'modified'));
Creates an instance of the watcher, that polls directory
every seconds
for changes
Initiates watching, starts polling directory for changes
Stops watching, clears polling. .start()
must be called again for any changed to happen
Stops watcher and removes all event listeners
This event is triggered whenever any files are modified
or deleted
. It's data is simply the combination of modified
and deleted
events' data. Example :
{
deleted: ["./remove-file", "./another-removed-file-somewhere"],
modified: ["./this-file-was-modified"],
}
Whenenver newly created files are detected, returns list of created filenames, like :
[
"./file_a",
"./file_b"
]
Whenenver modified files are detected, returns list of modified filenames, like :
[
"./file_a",
"./file_b"
]
Whenenver modified files are detected, returns list of modified filenames, like :
[
"./file_a",
"./file_b"
]
Inspired by http://stackoverflow.com/a/24789597