Gaze callback function runs multiple times on Windows 8.1
Code:
var gaze = require('gaze');
console.log('script loaded');
gaze(__dirname + '/../public/assets/javascripts/**/*', {maxListeners: 999}, function(err, watcher) {
console.log('gaze function called');
this.on('all', function(event, filepath) {
console.log(filepath + ' was ' + event);
});
});
On Ubuntu terminal:
script loaded
gaze function called
On Windows 8.1 PowerShell:
script loaded
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
gaze function called
He's also not actually watching the files when I run this code on windows, I have a feeling that it might be connected to this strange output. I'm guessing this ain't normal. Any ideas? Any extra information I can provide you?
I'm using Node v0.10.34
Try this instead:
gaze('**/*', {
cwd: __dirname + '/../public/assets/javascripts/',
maxListeners: 999
}, function(err, watcher) {
// ...
It works based on patterns, so when using absolute paths it is better to set the cwd instead.
Code:
var gaze = require('gaze');
console.log('script loaded');
gaze('**/*', {
cwd: __dirname + '/../public/assets/javascripts/',
maxListeners: 999
}, function(err, watcher) {
console.log('gaze function called');
this.on('all', function(event, filepath) {
console.log(filepath + ' was ' + event);
});
this.on('ready', function(watcher) {
console.log('ready');
});
});
Output:
script loaded
gaze function called
gaze function called
gaze function called
gaze function called
ready
ready
ready
ready
gaze function called
Hmm strange. I can't reproduce on Windows 7 and don't have access to a Win 8.1 machine atm. So, if you can track down the issue on Windows 8.1 that would be super helpful. Thanks!
I am not using PowerShell, just the command line on Windows 8.1. But I am not seeing this issue. So maybe it was fixed or it is something in PowerShell.