tiny-watcher
There is no such thing as fs.watch and this is a wrapper around it. Another one. Yep, there are lots of wrappers and I tried a couple for my project but found that they were all buggy in their own idiosyncratic ways. I needed one that was buggy in a specific way, so I coded up tiny-wrapper.
Example
var tiny = fs = rimraf = path = var somedir = "somedir" fsvar watcher = watcher watcher watcher // ADD TESTfs// REMOVE TESTfs// ADD TOTALfs// CHANGE TOTALfs// ADD TONNES (NOT IN SPECIFIED FILE LIST)fs /* * Setting watcher kill should stop the remove event * when total is removed with rimraf */
which produces
EXAMPLE: added testEXAMPLE: removed testEXAMPLE: added totalEXAMPLE: changed total
API
tiny()
The main object is a function that produces watchers for a specific directory an optional set of files.
var watcher =
watcher.on
Three events, added
, removed
and changed
are supported. The callback returns the filename.
watcher.emitWatched(event)
Cycle through all the files being monitored by the tiny-watcher instance and emit event
events for each one.
Useful for on-startup tasks.
watcher.close()
Calls the base fs method watcher.close()
INSTALL
npm install tiny-watcher
LICENSE
MIT