Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added event never fires #41

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

added event never fires #41

callumlocke opened this issue Jun 17, 2013 · 11 comments

Comments

@callumlocke
Copy link
Contributor

@callumlocke 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
Copy link
Contributor Author

@callumlocke 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
Copy link
Contributor Author

@callumlocke 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
Copy link

@bericp1 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
Copy link
Owner

@shama shama commented Sep 4, 2013

Fixed with 23cba6f

@shama shama closed this Sep 4, 2013
@scottcorgan
Copy link

@scottcorgan scottcorgan commented Oct 25, 2013

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

@brett-shwom
Copy link

@brett-shwom brett-shwom commented Oct 25, 2013

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

@scottcorgan
Copy link

@scottcorgan scottcorgan commented 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.

@brett-shwom
Copy link

@brett-shwom brett-shwom commented Oct 25, 2013

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

@scottcorgan
Copy link

@scottcorgan scottcorgan commented Oct 25, 2013

Exactly

@brett-shwom
Copy link

@brett-shwom brett-shwom commented Oct 25, 2013

Ah ok I was confusing this issue with #14.

@Herriau
Copy link

@Herriau 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.