segmentio/metalsmith — pull request #66 by aymericbeaumet (2014-07-16 23:47:16+00:00)
Title: Internal support for file watching

I really appreciate Metalsmith, but one feature I find is really missing is the possibility to watch files modifications to retrigger a build on-the-fly (without using an external build tool). We already discussed this problem and it appears it is not possible to do it properly in a plugin. This is why I took to the liberty to directly patch the core.

So here is my proposal. Please feel free to discuss, I need feedbacks on it.

Below are some examples of what my patch allows to do.

### API - `Metalsmith#watch`

```javascript
// Callback
Metalsmith(__dirname)
.watch(function onBuild(err, files, end) {
if (err) return console.log(err);
})
;

// Event Emitter
Metalsmith(__dirname)
.watch()
.on('error', function onError(err) {
console.log(err);
})
.on('ready', function onReady() {
})
.on('build', function onBuild(files, end) {
})
.on('end', function onEnd() {
})
;
```

### CLI - `metalsmith`

```bash
$ metalsmith --help
Usage: metalsmith [options]

Options:

-h, --help output usage information
-V, --version output the version number
-w, --watch [pattern] Watch for file modifications and re-trigger a build
```