Sentry
Sentry is a simple node tool to watch for file changes (using a path, wildcards, or regexes) and execute a function or shell command. It's like a watchr or guard for node.
Installation
$ npm install sentry2
Example
var sentry = ; // Watch changes in file.jssentry; // Watch changes on any file ending in .coffee one directory deepsentry; // Watch changes recursively on any files sentry; // Watch files recursively that match a regexsentry; // If you pass a string instead of a function it'll execute that child processsentry;
API
Sentry comes with two methods watch
and watchRegExp
.
sentry.watch(filePath, [task], callback)
When running a child process you may optionally pass a callback with the arguments (error, filename, stdout, stderr)
sentry;
Or just pass a callback and Sentry will pass the filename to the callback
sentry;
Feel free to use wildcards with extensions
// Find all files one directory deepsentry; // Find all files one directory deep ending in .coffeesentry; // Find all files recursivelysentry; // Find all files recursively ending in .txtsentry;
sentry.watchRegExp(root, regex, [task], callback)
Just like sentry.watch but instead you must pass a root directory and regular expression to match files against.
// Find all files in this folder that end in .coffeesentry; // Find all files in the adjacent 'test' folder that begin with `test_` and end in `.coffee`sentry;
To run tests
npm test