An open API service indexing awesome lists of open source software.

https://github.com/doowb/watch-cli

Watch files and execute an npm script when files change.
https://github.com/doowb/watch-cli

file-watcher watch watcher

Last synced: 5 months ago
JSON representation

Watch files and execute an npm script when files change.

Awesome Lists containing this project

README

          

# watch-cli [![NPM version](https://badge.fury.io/js/watch-cli.svg)](http://badge.fury.io/js/watch-cli)

> Command line wrapper for gaze to use in package.json scripts object.

### Install globally

**Install globally with [npm](npmjs.org)**

```bash
npm i -g watch-cli
```

## Usage

```bash
watch -p "**/*.js" -c "npm test"
```

### Options

Short | Long | Type | Description
---|---|---|---
`-p` | `--pattern` | `string` | [`glob`](https://github.com/isaacs/node-glob) pattern you are want to watch.
`-c` | `--command` | `string` | Command to execute on watched files change.

### Multi Patterns

It is possible to provide multi paterns, so if one of the files changed, the command will execute.
```
watch -p file1.js -p file2.fs -c command
```

### Exported environment variables

Environment variables available from the command string:

```
FILENAME Relative filename.
ABSOLUTE_FILENAME Asolute filename.
EVENT Event type. Is either 'changed', 'deleted' or 'added'.
```

Use it like this in Linux/macOS:

```
$ watch -p '**/*.js' -c 'jshint $FILENAME'
```

In Windows:

```
> watch -p "**/*.js" -c "jshint %FILENAME%"
```

## Author

**Brian Woodward**

+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)

## License
Copyright (c) 2015 Brian Woodward
Released under the MIT license

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 11, 2015._