node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


Simple file/directory watcher.


Simple file/directory watcher. (Node.js)

It's quite simple to create a wtchr for a directory.

wtchr(path, [options]);
  • an absolute dircetory path
  • persistent (boolean) default: true
  • interval (integer) default: 500
  • ignore (regexp) default: /(\/\.DS_Store$)/
var watch = wtchr('/my/watch/base/directory');

Wtchr provides simple event bindings. The event API is quite similar to jQuery events, so most of JS developers are familiar with it.

bind an event

.on(type, [selector], handler(path, curr lstat, prev lstat))

unbind an event

.off(type, [selector], [handler(path, curr lstat, prev lstat)])
  • one of the 3 supported types create / change / delete
  • a minimatch path selector (simply a filter)
  • a event handler
var watch = wtchr('/my/watch/base/directory')
watch.on("create", "*.js", function (path, curr, prev) {
  console.log("New file: " + path);


  .on("create", "*.js", function (path, curr, prev) {
    console.log("New file: " + path);
  .on("change", "*.js", function (path, curr, prev) {
    console.log("File changed: " + path);
  .on("delete", "*.js", function (path, curr, prev) {
    console.log("File deleted: " + path);

Simply destroy the wtchr object with the destroy method.

var watch = wtchr('/my/watch/base/directory')