Skip to content

Commit

Permalink
Merge branch 'master', remote-tracking branch 'origin'
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandpoulter committed Feb 1, 2013
2 parents 16ddd13 + 017fa84 commit adb3369
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions README.md
Expand Up @@ -11,19 +11,21 @@ Sentry is a simple node tool to watch for file changes (using a path, wildcards,
````javascript
var sentry = require('sentry2');

# Watch changes in file.js
sentry.watch('file.js', function (filename) {console.log("A change has been made in " + filename);});
// Watch changes in file.js
sentry.watch('file.js', function (error, filename) {
console.log("A change has been made in " + filename);
});

# Watch changes on any file ending in .coffee one directory deep
// Watch changes on any file ending in .coffee one directory deep
sentry.watch('fld/*.coffee', callback);

# Watch changes recursively on any files
// Watch changes recursively on any files
sentry.watch('fld/**/*', callback);

# Watch files recursively that match a regex
// Watch files recursively that match a regex
sentry.watchRegExp('fld/', /regex/, callback);

# If you pass a string instead of a function it'll execute that child process
// If you pass a string instead of a function it'll execute that child process
sentry.watch('file.coffee', 'coffee -c');
````

Expand All @@ -33,32 +35,32 @@ 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 `(err, stdout, stderr)`
When running a child process you may optionally pass a callback with the arguments `(error, filename, stdout, stderr)`

````javascript
sentry.watch('file.js', 'coffee -c', function (err, stdout, stderr) {/*...*/});
sentry.watch('file.js', 'coffee -c', function (error, filename, stdout, stderr) {/*...*/});
````

Or just pass a callback and Sentry will pass the filename to the callback

````javascript
sentry.watch('file.js', function (filename) {/*...*/});
sentry.watch('file.js', function (error, filename) {/*...*/});
````

Feel free to use wildcards with extensions

````javascript

# Find all files one directory deep
// Find all files one directory deep
sentry.watch('/folder/*', callback);

# Find all files one directory deep ending in .coffee
// Find all files one directory deep ending in .coffee
sentry.watch('/folder/*.coffee', callback);

# Find all files recursively
// Find all files recursively
sentry.watch('/folder/**/*', callback);

# Find all files recursively ending in .txt
// Find all files recursively ending in .txt
sentry.watch('/folder/**/*.txt', callback);
````

Expand All @@ -68,10 +70,10 @@ Just like sentry.watch but instead you must pass a root directory and regular ex

````javascript

# Find all files in this folder that end in .coffee
// Find all files in this folder that end in .coffee
sentry.watchRegExp('', /\.coffee$/, callback);

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

Expand Down

0 comments on commit adb3369

Please sign in to comment.