Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Apr 2, 2015
1 parent df2c25a commit daf53e3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,28 @@ Install chokidar via node.js package manager:
Then just require the package in your code:

```javascript
// One-liner
require('chokidar').watch('.', {ignored: /[\/\\]\./}).on('all', function(event, path) {
var chokidar = require('chokidar');

// One-liner for current directory, ignores .dotfiles
chokidar.watch('.', {ignored: /[\/\\]\./}).on('all', function(event, path) {
console.log(event, path);
});


var chokidar = require('chokidar');

var watcher = chokidar.watch('file, dir, or glob', {
ignored: /[\/\\]\./, persistent: true
ignored: /[\/\\]\./,
persistent: true
});

var log = console.log.bind(console);

watcher
.on('add', function(path) { log('File', path, 'has been added'); })
.on('addDir', function(path) { log('Directory', path, 'has been added'); })
.on('change', function(path) { log('File', path, 'has been changed'); })
.on('unlink', function(path) { log('File', path, 'has been removed'); })
// More events.
.on('addDir', function(path) { log('Directory', path, 'has been added'); })
.on('unlinkDir', function(path) { log('Directory', path, 'has been removed'); })
.on('error', function(error) { log('Error happened', error); })
.on('ready', function() { log('Initial scan complete. Ready for changes.'); })
Expand Down

0 comments on commit daf53e3

Please sign in to comment.