Watch specific files or directories and re-execute a given command, using `child_process.spawn` instead of the original `child_process.exec` to have a bit more of control. Forked from `watch-run` by `queckezz`
npm install watch-spawnImportant
This is a fork from watch-run that uses spawn instead of exec internally for the following reasons:
- spawn does not have a buffer limit for stdout
- spawn does not loses colored output when terminal allows it
- add option to specify several patterns passing several times the -p, --pattern option all the options will be
aggregated into a single array to pass to Gaze.
- add option to react only on certain events: added, changed, deleted or renamed.
- add verbose info, use -q, --quiet to reduce the noise. (the info about when the command is run and when it finish will always be printed regardless the value of --quiet)
- add option to skip executing the command if the command is already running -k, --skip-if-running.
Everything else is the same as the origina watch-run
> Re-execute a given command everytime something changes in a specific directory. Build upon gaze.
$ npm install -g watch-spawn
Via --help:
``
Usage: watch-spawn
Options:
-h, --help output usage information
-p, --pattern [pattern] glob pattern. More info: https://github.com/isaacs/minimatch
-i, --initial run
-d, --delay
-s, --stop-on-error stop watching and exit when errors occur in
-f, --fire-on-events , changed or deleted
-q, --quiet be as quiet as possible
-k, --skip-if-running skip if currently executing the
Examples:
# watch dir and execute cmd
$ watch-spawn -p 'lib/**' cat package.json
`
`bashlisten to changes on js/modules/*/.js and execute browserify
watch-spawn -p 'js/modules/*/.js' browserify main.js -o public/build.js
, deleted events and execute browserifyMIT