start-watch
Version:
Watch task for Start
59 lines (45 loc) • 2.31 kB
Markdown
# start-watch
[](https://www.npmjs.com/package/start-watch)
[](https://travis-ci.org/start-runner/watch)
[](https://ci.appveyor.com/project/start-runner/watch)
[](https://codecov.io/github/start-runner/watch)
[](https://gemnasium.com/start-runner/watch)
Watch task for [Start](https://github.com/start-runner/start).
## Install
```sh
npm install --save-dev start-watch
# or
yarn add --dev start-watch
```
## Usage
```js
import Start from 'start';
import reporter from 'start-pretty-reporter';
import files from 'start-files';
import clean from 'start-clean';
import watch from 'start-watch';
import read from 'start-read';
import babel from 'start-babel';
import write from 'start-write';
import mocha from 'start-mocha';
import inputConnector from 'start-input-connector';
cosnt start = Start(reporter());
export const dev = () => start(
files('build/'),
clean(),
watch('lib/**/*.js')((changedFiles) => start(
inputConnector(changedFiles),
read(),
babel(),
write('build/')
))
);
```
See [documentation](https://github.com/start-runner/start#readme) for details.
:point_right: Note that this task may not work properly with tasks like [start-webpack](https://github.com/start-runner/webpack) and [start-karma](https://github.com/start-runner/karma) which have their own file watching functionality.
## Arguments
`watch(files, events, options)(callback)`
* `files` – [Chokidar "file, dir, glob, or array"](https://github.com/paulmillr/chokidar)
* `events` – [Chokidar events array](https://github.com/paulmillr/chokidar#getting-started), `[ 'change', 'add' ]` by default
* `options` – [Chokidar options](https://github.com/paulmillr/chokidar#api), `{ persistent: true }` by default
* `callback(changedFiles)` – callback function which will be called with an array of matched and changed files