Watch files (using a path, wildcards, or a regex) and execute a function or shell command.
$ npm install sentry2
var sentry = require'sentry2';// Watch changes in file.jssentrywatch'file.js'console.log"A change has been made in " + filename;;// Watch changes on any file ending in .coffee one directory deepsentrywatch'fld/*.coffee' callback;// Watch changes recursively on any filessentrywatch'fld/**/*' callback;// Watch files recursively that match a regexsentrywatchRegExp'fld/' /regex/ callback;// If you pass a string instead of a function it'll execute that child processsentrywatch'file.coffee' 'coffee -c';
Sentry comes with two methods
When running a child process you may optionally pass a callback with the arguments
(error, filename, stdout, stderr)
sentrywatch'file.js' 'coffee -c' /*...*/;
Or just pass a callback and Sentry will pass the filename to the callback
Feel free to use wildcards with extensions
// Find all files one directory deepsentrywatch'/folder/*' callback;// Find all files one directory deep ending in .coffeesentrywatch'/folder/*.coffee' callback;// Find all files recursivelysentrywatch'/folder/**/*' callback;// Find all files recursively ending in .txtsentrywatch'/folder/**/*.txt' 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 .coffeesentrywatchRegExp'' /\.coffee$/ callback;// Find all files in the adjacent 'test' folder that begin with `test_` and end in `.coffee`sentrywatchRegExp'../tests/' /^test_,.coffee$/ callback;