mkitt/watchn — Issue #4: Not monitoring directories for me
Author: alindsay55661
Created: 2011-12-07 21:52:51+00:00
State: open

I was very excited to see this project. I setup a quick example and out of the box it isn't working for me when I monitor directories. If I watch a file then it works fine but the callback is not being fired when I watch directories.

Here is my quick example:
----------------------------------------------------------------
var cp = require('child_process');

module.exports.init = function(watchn) {

// watchn.watch('build', ['./modules/js/AlertGrid.js'], function(options) { <--- this works fine
watchn.watch('build', ['./modules/js/'], function(options) {

console.log(options); // <------ doesn't execute when watching the directory

// File has changed
if (options.curr > options.prev) {

console.log('');
console.log('--------------------------------------');
console.log('CHANGE DETECTED');
console.log('--------------------------------------');
console.log('');

cp.exec('./build.sh -c', function(error, stdout, stderr) {

if (error !== null) {
console.log(stderr);
} else {
console.log(stdout);
}
})
}

})

}