Watch for file changes in node (like watchr or guard for ruby).
CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


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.


$ npm install sentry


sentry = require 'sentry'

# Watch changes in file.js 'file.js', (filename) -> console.log "A change has been made in #{file}"

# Watch changes on any file ending in .coffee one directory deep 'fld/*.coffee', ->

# Watch changes recursively on any files 'fld/**/*', ->

# Watch files recursively that match a regex
sentry.watchRegExp 'fld/', /regex/, ->

# If you pass a string instead of a function it'll execute that child process '', 'coffee -c'


Sentry comes with two methods watch and watchRegExp., [task], callback)

When running a child process you may optionally pass a callback with the arguments (err, stdout, stderr) 'file.js', 'coffee -c', (err, stdout, stderr) ->

Or just pass a callback and Sentry will pass the filename to the callback 'file.js', (filename) ->

Feel free to use wildcards with extensions

# Find all files one directory deep '/folder/*', ->

# Find all files one directory deep ending in .coffee '/folder/*.coffee', ->

# Find all files recursively '/folder/**/*', ->

# Find all files recursively ending in .txt '/folder/**/*.txt', ->

sentry.watchRegExp(root, regex, [task], callback)

Just like but instead you must pass a root directory and regular expression to match files against.

# Find all files in this folder that end in .coffee
sentry.watchRegExp '', /\.coffee$/, ->

# Find all files in the adjacent 'test' folder that begin with `test_` and end in `.coffee`
sentry.watchRegExp '../tests/', /^test_,.coffee$/, ->

To run tests

Sentry uses Jasmine-node for testing. Simply run the jasmine-node command with the coffeescript flag

jasmine-node spec --coffee