Watch globs and execute a function upon change, with intelligent defaults for debouncing and queueing.
var watch = ;;// Raw chokidar instancevar watcher = ;// Listen for the 'change' event to get `path`/`stat`// No async completion available because this is the raw chokidar instancewatcher;// Listen for other events// No async completion available because this is the raw chokidar instancewatcher;
Takes a path string, an array of path strings, a glob string or an array of glob strings as
globs to watch on the filesystem. Also optionally takes
options to configure the watcher and a
fn to execute when a file changes.
Returns an instance of chokidar.
fn is passed, it will be called when the watcher emits a
unlink event. It is automatically debounced with a default delay of 200 milliseconds and subsequent calls will be queued and called upon completion. These defaults can be changed using the
fn is passed a single argument,
callback, which is a function that must be called when work in the
fn is complete. Instead of calling the
callback function, async completion can be signalled by:
Once async completion is signalled, if another run is queued, it will be executed.
If set to
fn is called during chokidar instantiation as it discovers the file paths. Useful if it is desirable to trigger the
fn during startup.
Passed through to chokidar, but defaulted to
true instead of
The delay to wait before triggering the
fn. Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files.
Whether or not a file change should queue the
fn execution if the
fn is already running. Useful for a long running
An event name or array of event names to listen for. Useful if you only need to watch specific events.
String | Array<String>
[ 'add', 'change', 'unlink' ]
Options are passed directly to lodash.debounce and chokidar, so all their options are supported. Any debounce-related options are documented in lodash.debounce. Any chokidar-related options are documented in chokidar.