gaze icon indicating copy to clipboard operation
gaze copied to clipboard

event added firing incorrectly when files added

Open davidmoshal opened this issue 10 years ago • 9 comments

The following glob fires 'added' event when any directory is added: Given:

gaze = new Gaze 'src/templates/**/*.html'
gaze.on 'all', (evt, p) ->
  switch evt
    when 'added'
        console.log 'added: ' + p

Then: the 'added' event will fire if a directory is added (e.g. src/templates/dir1) OS = OSX Mavericks

davidmoshal avatar Dec 13 '13 10:12 davidmoshal

Which version of gaze and node.js? Thanks!

shama avatar Dec 13 '13 16:12 shama

latest versions of both

On Fri, Dec 13, 2013 at 8:13 AM, Kyle Robinson Young < [email protected]> wrote:

Which version of gaze and node.js? Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/shama/gaze/issues/61#issuecomment-30521041 .

davidmoshal avatar Dec 13 '13 18:12 davidmoshal

Yeah i've got the same issue here.

I got the following directory structure:

app
  lib
    - should only watch in here.
  app.js

I instantiate a new Gaze watcher with the glob lib/** and if I then log the watched files with this.relative(), I get something like this:

{
   'lib/':[
      'base-styles/',
      'boot/'
   ],
   '.':[
      'lib/'
   ],
   'lib/base-styles/':[
      'component.json',
      'index.css'
   ],
   'lib/boot/':[
      'component.json',
      'index.css',
      'index.html',
      'index.js'
   ]
}

Which seems completely right.

But as soon as I change something that is not in the lib directory like adding a new directory outside of lib in the app folder, it fires the added event anyways. But If I remove the directory nothings happening. There's something wrong with the added event handler i guess.

PATH/app/newDirectory/ was added

Or am I doing something wrong here?

btw i'm using the latest version of gaze and node.js stable

queckezz avatar Dec 15 '13 16:12 queckezz

Consistently having this issue. node 0.10.24, OSX

yocontra avatar Dec 28 '13 19:12 yocontra

Just an update. This (and just about every other issue in the tracker) is fixed in the v0.5 branch. It is using quite a different approach then v0.4 but remains backwards compatible. The biggest difference is it will now only use native events then fall back to stat polling if EMFILE is hit (but still reports the error in case you want to notify users to increase their limits). You can also force it into stat polling mode, if needed, such as with watching files on networked drives, etc. Also it is way more responsive; for most events, less than 1ms response time consistently.

Just needs a whole lot more testing, especially on Windows.

shama avatar Jan 01 '14 05:01 shama

@shama Awesome! Thanks for keeping this library going strong. Do you have a gittip?

yocontra avatar Jan 01 '14 07:01 yocontra

Yes I do but don't really advertise it. :)

shama avatar Jan 01 '14 17:01 shama

Ok v0.5 stable on osx/windows but still some issues to resolve on linux.

Also a note, I don't really want to bother too much with node v0.8 so I'm just going to give users a bundled gaze v0.4 if they're still on node v0.8. Which should be fine, IMO, as gaze v0.5 is backwards compatible and were getting close to node v0.12.

@Contra Which versions of node does gulp currently target? I saw that glob-watcher says "node": ">= 0.4.0" but I assumed that wasn't true. :)

shama avatar Jan 04 '14 06:01 shama

@shama gulp is 0.9+ due to 0.8 streams being bad. The actual glob-watcher code is 0.4+ (or whatever the highest dependency version is so probably higher)

yocontra avatar Jan 04 '14 06:01 yocontra