gaze icon indicating copy to clipboard operation
gaze copied to clipboard

Change triggers add event and change event

Open nickcarenza opened this issue 11 years ago • 5 comments

Setup

gaze('**/*.js');
gaze.on('all', function(event, filepath) {
    console.log('event', event);
    console.log('filepath', filepath);
});

gaze.watched:

files { '/Users/me/project/src/':
   [ '/Users/me/project/src/index.js',
     '/Users/me/project/src/process.js' ] }

I change process.js

event added
filepath /Users/me/project/src/process.js
event changed
filepath /Users/me/project/src/process.js

nickcarenza avatar Jun 13 '14 03:06 nickcarenza

Which version of gaze, node.js and OS/version? Thanks!

shama avatar Jun 13 '14 03:06 shama

@shama Seems to be duplicate/part of #121.

RReverser avatar Jun 14 '14 10:06 RReverser

gaze 0.6.4 mac osx mavericks 10.9.3 node v0.10.28

nickcarenza avatar Jun 18 '14 03:06 nickcarenza

Are you editing with SublimeText 3 or another editor that does atomic saves? Eg write to temp file, then mv tmp to file? (See http://stackoverflow.com/questions/20634684/what-is-sublime-text-doing-when-i-save-a-file)

DavidSouther avatar Jun 26 '14 22:06 DavidSouther

Using vim :w. Not sure what that triggers on the filesystem, but I would expect not to get an add event for a file multiple times without a delete event. I just don't feel like the developer should have to do this:

var files = {};
watcher.on('added', function(path){
    if( ! files[path] ) ...

I suppose if the lib is just passing on system events it doesn't want to try to figure out which ones make sense for everyone, so perhaps an option could be available to ignore multiple 'added' events and just get the 'changed' events.

nickcarenza avatar Jun 27 '14 00:06 nickcarenza