# cha-watch

> Watch extension for cha.

Latest version **0.1.0** (published 2014-03-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install cha-watch
pnpm add cha-watch
yarn add cha-watch
bun add cha-watch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2014-03-16 |
| First published | 2014-03-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | yuanyan |
| Maintainers | yuanyan |
| Keywords | cha, extension, watch |

## Links

- npm: https://www.npmjs.com/package/cha-watch
- Repository: https://github.com/chajs/cha-watch
- Issues: https://github.com/chajs/cha-watch/issues
- npm.io page: https://npm.io/package/cha-watch

## Dependencies (3)

- [gaze](https://npm.io/package/gaze.md) ^0.5.1
- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [es6-promise](https://npm.io/package/es6-promise.md) ^0.1.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2014-03-16

## README

cha-watch
=========
> Watch extension for cha.

## How to run watch task?

```js
var cha = require('cha')
var tasks = require('./tasks')

// Require watch extension.
cha.watch = require('cha-watch')

cha.in('read',    tasks.read)
   .in('cat',     tasks.cat)
   .in('coffee',  tasks.coffee)
   .in('write',   tasks.write)
   .in('uglifyjs',tasks.uglifyjs)

// Start watcher.
cha.watch('./fixtures/coffee/*.coffee', {
    cwd: __dirname,
    immediately: true
}, function(filepath, event, watched){

    cha().read(watched)
        .coffee()
        .cat()
        .uglifyjs()
        .write('./out/foobar3.js')
})

```

To run the command we prepend our script name with run:
```sh
$ npm run watch

> cha@0.0.1 watch
> node ./test/watch

read /test/fixtures/coffee/bar.coffee
read /test/fixtures/coffee/foo.coffee
concat /test/fixtures/coffee/bar.coffee,/test/fixtures/coffee/foo.coffee
write ./out/foobar3.js
```

## API
```js
cha.watch(patterns, options, callback)
```

### patterns
Defines what file patterns will watch. Can be a string or an array of files and/or minimatch patterns.

### options
* cwd {string} Set the current working directory, default is `process.cwd()`.
* immediately {boolean} Trigger the callback at startup of the watcher.
* interval {integer} Interval to pass to fs.watchFile.
* debounceDelay {integer} Delay for events called in succession for the same file/event.

### callback(filepath, event, watched)
Trigger the callback when an added, changed or deleted event occurs.

* filepath - The path of the file that added, changed or deleted.
* event
    * added - When a file has been added to a watch directory.
    * changed - When a file has been changed.
    * deleted - When a file has been deleted.
* watched - The currently watched files.

---
_Source: https://npm.io/package/cha-watch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
