1. nswatch
Like gulp.watch but for npm scripts.
nswatch
Package: nswatch
Created by: egoist
Last modified: Wed, 22 Jun 2022 12:02:29 GMT
Version: 0.2.0
License: MIT
Downloads: 100
Repository: https://github.com/egoist/nswatch

Install

npm install nswatch
yarn add nswatch

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code