Simple file/directory watcher.
Simple file/directory watcher. (Node.js)
It's quite simple to create a wtchr for a directory.
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)])
var watch = wtchr'/my/watch/base/directory'watchon"create" "*.js"console.log"New file: " + path;;watchoff"create";
wtchr'/my/watch/base/directory'on"create" "*.js"console.log"New file: " + path;on"change" "*.js"console.log"File changed: " + path;on"delete" "*.js"console.log"File deleted: " + path;off"create"off"delete";
Simply destroy the wtchr object with the destroy method.
var watch = wtchr'/my/watch/base/directory'watchdestroy;