gaze icon indicating copy to clipboard operation
gaze copied to clipboard

Gaze callback function runs multiple times on Windows 8.1

Open iMoses opened this issue 11 years ago • 4 comments

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

iMoses avatar Dec 26 '14 09:12 iMoses

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.

shama avatar Dec 26 '14 17:12 shama

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

iMoses avatar Dec 27 '14 20:12 iMoses

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!

shama avatar Dec 27 '14 21:12 shama

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.

docluv avatar Mar 18 '15 15:03 docluv