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

unwatched file still trigger "all" event when modified #258

Closed
MoOx opened this issue Mar 17, 2015 · 2 comments
Closed

unwatched file still trigger "all" event when modified #258

MoOx opened this issue Mar 17, 2015 · 2 comments

Comments

@MoOx
Copy link

MoOx commented Mar 17, 2015

Here is my scenario:

I watch 2 files A & B, I add them & execute a function on "all" event. If I unwatch B & modify this B file, I still have the watcher triggering "all" event, is this on purpose ? Looks like a bug.

To reproduce here is a branch: https://github.com/cssnext/cssnext/tree/watch-imported

Here is the part that add/unwtach appropriate files

https://github.com/cssnext/cssnext/blob/fbfaff5053180192e146cdde8d1986a39e0d3980/bin/cssnext.js#L107-L113

Here is the broken test https://github.com/cssnext/cssnext/blob/fbfaff5053180192e146cdde8d1986a39e0d3980/test/cli.js#L177-L189

I have also tried by hand. To reproduce:

  1. clone the repo, checkout the branch watch-imported, then npm install
  • run the following command bin/cssnext.js --watch test/fixtures/cli.watch-import.css test/fixtures/cli.watch-import.actual.css
  • modify test/fixtures/cli.watch-import.css with /**/ @import "cli.watch-import-import.css";: you will see that the imported file has been added
  • trigger a change in this imported file test/fixtures/cli.watch-import-import.css (this is working as expected)
  • now modify test/fixtures/cli.watch-import.css with /**/: you will see that the file is _unwatch_ed
  • trigger a change in this (now supposed to be unwatched) previously imported file test/fixtures/cli.watch-import-import.css: you got a change triggered by the watcher (this is not what I expect)
@es128
Copy link
Collaborator

es128 commented Mar 17, 2015

Thanks for reporting. Can you please provide a script or procedure to reproduce using only chokidar? The example.js script in the repo is usually a good starting point.

@es128
Copy link
Collaborator

es128 commented Mar 17, 2015

For reference, here are the passing tests for unwatch: https://github.com/paulmillr/chokidar/blob/master/test.js#L1109

Perhaps modifying one of them to act on individual files like in your scenario will expose the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants