Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/egoist/nswatch
Like gulp.watch but for npm scripts.
https://github.com/egoist/nswatch
Last synced: 2 months ago
JSON representation
Like gulp.watch but for npm scripts.
- Host: GitHub
- URL: https://github.com/egoist/nswatch
- Owner: egoist
- License: mit
- Created: 2016-08-29T01:10:07.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-08-03T06:37:42.000Z (over 1 year ago)
- Last Synced: 2024-12-09T22:34:54.387Z (2 months ago)
- Language: TypeScript
- Size: 257 KB
- Stars: 101
- Watchers: 5
- Forks: 2
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# nswatch
[](https://npmjs.com/package/nswatch) [](https://npmjs.com/package/nswatch) [](https://circleci.com/gh/egoist/nswatch)
> Like gulp.watch but for npm scripts.
## Install
```bash
$ npm install -D nswatch
```## Usage
Assuming you have an npm script `build` to compile something, then drop a `watch.js` in your project:
```js
import { watch } from "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:
```js
// 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
```bash
$ npm install -g nswatch
```You can also use `nswatch` as a command-line program:
### Configure `watch` in `package.json`
```json
{
"watch": {
"./src/*.js": ["build"],
"./src/*.css": "compile!minify"
}
}
```Then run:
```bash
$ nswatch
```Or you can pass the config via CLI arguments, this way configurations in `package.json` will be ignored.
```bash
# in parallel
$ nswatch "src/*.js" --script foo --script bar# in sequence
$ nswatch "src/*.js" --script "foo!bar"
```## Author
**nswatch** © [EGOIST](https://github.com/egoist), Released under the [MIT](https://egoist.mit-license.org/) License.
Authored and maintained by EGOIST with help from contributors ([list](https://github.com/egoist/nswatch/contributors)).> [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@rem_rin_rin](https://twitter.com/rem_rin_rin)