# penumbra-watch

> Watch files for penumbra

Latest version **1.2.3** (published 2016-01-12) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2016-01-12 |
| First published | 2015-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Quentin Engles |
| Maintainers | hollowdoor |
| Keywords | watch, penumbra, tasks |

## Links

- npm: https://www.npmjs.com/package/penumbra-watch
- Repository: https://github.com/hollowdoor/penumbra_watch
- Homepage: https://github.com/hollowdoor/penumbra_watch#readme
- Issues: https://github.com/hollowdoor/penumbra_watch/issues
- npm.io page: https://npm.io/package/penumbra-watch

## Dependencies (1)

- [chokidar](https://npm.io/package/chokidar.md) ^1.3.0

## Recent versions

- 1.2.3 (latest) — 2016-01-12
- 1.2.2 — 2016-01-12
- 1.0.1 — 2015-12-23
- 1.0.0 — 2015-12-02

## README

penumbra-watch
==============

Install
-------

`npm install --save penumbra-watch`

Or if you are working locally, but don't want `penumbra-watch` as a dependency.

`npm install --save-dev penumbra-watch`

Usage
-----

Install `penumbra`, and `vinyl-fs` to do this example.

```javascript
var pen = require('penumbra')(),
    //Make sure to pass the pen instance into the penumbra watch function.
    watch = require('penumbra-watch')(pen),
    fs = require('vinyl-fs');


pen.task('move', function * (){
    console.log('moving files');
    yield [
        fs.src(['./*.js']),
        map(log),
        fs.dest('./output')
    ];
});

watch('.', {
    cwd: process.cwd()
}, 'move');
```

`watch` can also be simply called as:

```javascript
watch('.', 'move', 'anotherTask');
```

or

```javascript
watch('.', function(){

}, /*... more functions, or penumbra tasks.*/);
```

Interface
---------

### require('penumbra-watch')(pen) -> watch

Pass a penumbra instance to the `pen` argument to use tasks in the watch constructor.

If you don't you can still use a callback, but you won't be able to use tasks directly in the watch function.

### watch(files, options, callback|task, ..., task) -> chokidar watcher

files can be one of these:

-	file name
-	file glob
-	array of file names, or globs

`options` are the same as **chokidar**.

The rest of the arguments can be a **callback, or a task string**.

`penumbra` tasks will be run before callbacks.

Look at [chokidar](https://www.npmjs.com/package/chokidar) to learn more.

Use with a callback
-------------------

```javascript
var pen = require('penumbra')(),
    watch = require('penumbra-watch')(pen),
    fs = require('vinyl-fs');


pen.task('move', function * (){
    console.log('moving files');
    yield [
        fs.src(['./*.js']),
        map(log),
        fs.dest('./output')
    ];
});

watch('.', {
    cwd: process.cwd()
}, function(){
    console.log('ready to move');
    pen.exec('move').then(function(){
        console.log('done moving');
    });
});
```

Use with [browser-sync](https://browsersync.io/)
------------------------------------------------

```javascript
var bs = require('browser-sync').create(),
    reload = bs.reload,
    pen = require('penumbra')(),
    watch = require('penumbra-watch')(pen);

pen.task('serve', function * (){
    bs.init({server: '.'});
    //Here callback functions, and penumbra tasks are mixed.
    watch('.', reload, 'anotherTask', console.log.bind(console));
});

pen.task('anotherTask', function * (){
    /*This task is run before the reload callback.*/
    console.log('anotherTask is running');
    /*... Do some stuff here.*/
});
```

About
-----

Use this module with `penumbra`.

If you would like a similar, but different interface then [gulp-watch](https://www.npmjs.com/package/gulp-watch) will also work with `penumbra`. [chokidar](https://www.npmjs.com/package/chokidar) itself will also work quite well.

`penumbra-watch` is just a little module to help decrease the code to start a file watcher using `penumbra`.

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