A wrapper and enhancements for fs.watch (with 0 dependencies).
npm install node-watch
var watch = ;;
This is a completely rewritten version, much faster and in a more memory-efficient way. So with recent nodejs under OS X or Windows you can do something like this:
// watch the whole disk;
The events provided by the callback function is either
remove, which is less confusing to
The usage and options of
node-watch is fully compatible with fs.watch.
persistent: <Boolean>default = true
recursive: <Boolean>default = false
encoding: <String>default = 'utf8'
filter: <RegExp | Function>filter using regular expression or custom function.
// watch only for json files;// ignore node_modules;
The watch function returns a fs.FSWatcher like object as the same as
fs.watch (>= v0.4.0).
var watcher = ;watcher;watcher;// closewatcher;// is closed?watcher
The watcher object is also an instance of EventEmitter. This's a list of methods for watcher specifically:
.getMaxListeners##### Extra methods
.isCloseddetect if the watcher is closed
Windows, node < v4.2.5
#!/usr/bin/env node//;var watcher =processargv2 || './' recursive: true consolelog;process;
Monitoring chrome from disk:
$ watch / | grep -i chrome
Copyright (c) 2012-2017 yuanchuan