Closed juliangruber closed 8 years ago
💯 thanks for starting this!
would list also have to be async, then?
Removing https://github.com/juliangruber/filewatcher/blob/master/index.js#L46-L51 makes the tests pass. That workaround re-adds the directory from the previous test, letting the next one fail.
I merged this into https://github.com/fgnass/filewatcher/tree/remove-sync and added fix that makes the tests pass again. I added you @juliangruber as collaborator in case you would like to help out landing this in master and cutting a new release.
i was thinking we should keep lines 46-51 but instead have another means of checking whether a file is already being watched, like watchers[file] = { watcher: watcher }
, so if you check !!watchers[file]
it tells you whether the file is being watched, but !!watchers[file].watcher
tells you whether also a watcher is set up.
In my fix the lines are still there. They just no longer use the public API to re-add the watcher.
published to npm as 3.0.1
This is a WIP pull request for removing those *Sync calls. Unless clearly stated, it's better for a node program - and more expected of it - not to perform any synchronous calls.
The tests are currently failing because
.removeAll()
depends on.list()
to always return all the watchers, however with the async implementation there's a moment in time where a file is still being watched but its watcher isn't inside thewatchers
array.This change is