added event never fires #41

Closed
callumlocke opened this Issue Jun 17, 2013 · 11 comments

Comments

Projects
None yet
6 participants
@callumlocke
Contributor

callumlocke commented Jun 17, 2013

I've got Gaze set up as per the first example under Usage in the readme (except I'm using a more general watch pattern, /some/path/**/*.*).

When I create a new file, the added event doesn't fire (and neither does the all event).

The changed and deleted events work fine.

This is not the same as issue #14, as I don't get any added events, even for files created in pre-existing directories. When I rename a file that is being watched, I get the deleted event for the old filename, but no added event for the new one. Also, subsequent changes to the file don't trigger changed events. Basically Gaze never seems to pick up new files, but it works fine for all files that existed when I first called gaze(...).

I'm using Node v0.10.8 on OS X Mountain Lion.

Any idea what the problem could be?

@callumlocke

This comment has been minimized.

Show comment
Hide comment
@callumlocke

callumlocke Jun 17, 2013

Contributor

I just tried this to see if there's any problem with fs.watch on my system:

require('fs').watch('app', {persistent: true}, function(event, filename) {
  console.log('EVENT', event);
  console.log('FILENAME', filename);
});

I saved the above as watch.js and ran it with node watch in the terminal. Then in a new terminal I ran touch app/foo to create a new file inside the app directory. The first terminal printed out:

EVENT rename
FILENAME foo

I think this is the expected output (?), so it seems that fs.watch does notice creation of new files correctly on my system.

Contributor

callumlocke commented Jun 17, 2013

I just tried this to see if there's any problem with fs.watch on my system:

require('fs').watch('app', {persistent: true}, function(event, filename) {
  console.log('EVENT', event);
  console.log('FILENAME', filename);
});

I saved the above as watch.js and ran it with node watch in the terminal. Then in a new terminal I ran touch app/foo to create a new file inside the app directory. The first terminal printed out:

EVENT rename
FILENAME foo

I think this is the expected output (?), so it seems that fs.watch does notice creation of new files correctly on my system.

@callumlocke

This comment has been minimized.

Show comment
Hide comment
@callumlocke

callumlocke Jun 17, 2013

Contributor

OK I just solved my own problem, but I'm not sure why this made a difference, so you might want to treat this as a bug...

When I changed the watch pattern from an absolute path to a relative one, it worked.

i.e. I changed /some/path/**/*.* to path/**/*.* (My watcher script is /some/watch.js)

Once I made that change, the added event started working.

Contributor

callumlocke commented Jun 17, 2013

OK I just solved my own problem, but I'm not sure why this made a difference, so you might want to treat this as a bug...

When I changed the watch pattern from an absolute path to a relative one, it worked.

i.e. I changed /some/path/**/*.* to path/**/*.* (My watcher script is /some/watch.js)

Once I made that change, the added event started working.

@bericp1

This comment has been minimized.

Show comment
Hide comment
@bericp1

bericp1 Jul 2, 2013

I'm also experiencing this problem. I have a global config that files throughout my project reference for various config variables including paths which are all absolute and are being passed to gaze. When I add new files to folders being watched, the added event doesn't fire for me either.

I'm on the latest version of gaze (0.4.0)

bericp1 commented Jul 2, 2013

I'm also experiencing this problem. I have a global config that files throughout my project reference for various config variables including paths which are all absolute and are being passed to gaze. When I add new files to folders being watched, the added event doesn't fire for me either.

I'm on the latest version of gaze (0.4.0)

@shama

This comment has been minimized.

Show comment
Hide comment
@shama

shama Sep 4, 2013

Owner

Fixed with 23cba6f

Owner

shama commented Sep 4, 2013

Fixed with 23cba6f

@shama shama closed this Sep 4, 2013

@scottcorgan

This comment has been minimized.

Show comment
Hide comment
@scottcorgan

scottcorgan Oct 25, 2013

I am currently still experiencing this issue using node 0.10.21. The 'added' event doesn't fire

I am currently still experiencing this issue using node 0.10.21. The 'added' event doesn't fire

@brett-shwom

This comment has been minimized.

Show comment
Hide comment
@brett-shwom

brett-shwom Oct 25, 2013

Could you please provide more context? Your gruntfile and the exact steps I can take to reproduce the issue.

Could you please provide more context? Your gruntfile and the exact steps I can take to reproduce the issue.

@scottcorgan

This comment has been minimized.

Show comment
Hide comment
@scottcorgan

scottcorgan Oct 25, 2013

Ya sorry about that:

gaze('**', function (err, watcher) {
  // doing stuff here

  this.on('all', function (evt, filePath) {
    // react to file change
  });
});

I tried it with both ** and **/*. It works on delete and change, but not file add.

Ya sorry about that:

gaze('**', function (err, watcher) {
  // doing stuff here

  this.on('all', function (evt, filePath) {
    // react to file change
  });
});

I tried it with both ** and **/*. It works on delete and change, but not file add.

@brett-shwom

This comment has been minimized.

Show comment
Hide comment
@brett-shwom

brett-shwom Oct 25, 2013

You mean that it doesn't detect any file adds at all?

You mean that it doesn't detect any file adds at all?

@scottcorgan

This comment has been minimized.

Show comment
Hide comment

Exactly

@brett-shwom

This comment has been minimized.

Show comment
Hide comment
@brett-shwom

brett-shwom Oct 25, 2013

Ah ok I was confusing this issue with #14.

Ah ok I was confusing this issue with #14.

@Herriau

This comment has been minimized.

Show comment
Hide comment
@Herriau

Herriau Sep 10, 2014

I am using the latest version as of writing (0.6.4, node 0.10.31, OS X 10.10) and this is still an issue, i.e. using a relative path as the pattern works but specifying an absolute path does not.

Herriau commented Sep 10, 2014

I am using the latest version as of writing (0.6.4, node 0.10.31, OS X 10.10) and this is still an issue, i.e. using a relative path as the pattern works but specifying an absolute path does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment