Skip to content
Like gulp.watch but for npm scripts.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
media
src
.editorconfig
.gitattributes
.gitignore
.npmignore
LICENSE
README.md
circle.yml
cli.js
package.json
test.js

README.md

nswatch

NPM version NPM downloads Build Status

Like gulp.watch but for npm scripts.

Install

$ npm install -D nswatch

Usage

Assuming you have an npm script build to compile something, then drop a watch.js in your project:

const watch = require('nswatch')

watch('src/*.js', ['build'])

When you run node watch, the npm run build will be invoked right away, and will also be invoked when file changes are detected.

Parallel and Sequence

Array will be treated as parallel, String will be treated as sequence:

// run in parallel
watch('src/a.js', ['task-a', 'task-b'])
// run in sequence
// use ! as seperator
watch('src/b.js', 'task-a!task-b')

CLI

$ npm install -g nswatch

You can also use nswatch as a command-line program:

Configure watch in package.json

{
  "watch": {
    "./src/*.js": ["build"],
    "./src/*.css": "compile!minify"
  }
}

Then run:

$ nswatch

Or you can pass the config via CLI arguments, this way configurations in package.json will be ignored.

# in parallel
$ nswatch "src/*.js" --script foo --script bar

# in sequence
$ nswatch "src/*.js" --script "foo!bar"

Author

nswatch © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

You can’t perform that action at this time.