node package manager


A simple program to watch files and directories and react on changes.

Install with npm [-g] install pattern-watcher.

Example, something that I'm using as I'm writing this file:

./bin/watcher --path --command "markdown > README.html"

As a more interesting example, the command

./bin/watcher --path . --rules watcher.yml

watches the current directory and whenever something changes there, the rules from watcher.yml are applied in order. By the way, this is what I use during development, and it's bound to npm run-script watch.

The rules file syntax is straightforward YAML, as the contents of the included watcher.yml show. Here is an excerpt:

  includes: "\.js$"
  excludes: "\.min\.js$"
    - "./node_modules/.bin/jslint {{path}}"
    - "./node_modules/.bin/mocha tests"

This will run jslint on any Javascript file in this source tree, unless minified, as soon as it is modified, and run the unit tests afterwards.