watchree
v0.1.4
Published
File tree watcher
Downloads
2
Readme
watchree
A wrapper around fs.watch
for recursively watching a directory of files.
Purpose
I found other file watchers such as
were either slow to start up or unreliable. I created watchtree to watch a project directory with more than 40,000 files; it initializes in under 500ms.
The only fast and reliable library I found was facebook/watchman, but I didn't like that it dependend on a separate service that had to be built and installed.
Install
npm install watchree --save-dev
Example
var watchTree = require('watchree');
watchTree(__dirname, {
excludeFiles: /^hg-|(^|[\/\\])(\.|Thumbs\.db$|nohup\.out$)|___jb_(old|bak)___$|\.(pyc|tar\.gz|orig)$/,
excludeDirs: /^(node_modules|bower_components|sql|artifacts|session|logs|cache|plugins\/ezc)$|(^|[\/\\])\./
})
.on('ready', function(files) {
console.log('watch initialized on '+files.length+' files');
})
.on('modify',function(files) {
console.log('modify',files);
})
.on('create',function(files) {
console.log('create',files);
})
.on('delete',function(files) {
console.log('delete',files);
})
.on('all', function(files) {
console.log('created, modified or deleted',files);
});
License
watchree is made available under the terms of the MIT license. See the LICENSE file that accompanies this distribution for the full text of the license.