paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
10.8k stars 574 forks source link

fix readyCount logic #1288

Closed JLHwung closed 1 year ago

JLHwung commented 1 year ago

This PR fixes readyCount logic.

Previously the this._readyCount will be doubled whenever watcher.add() is called, I believe it should have been only doubling the ready count change (hence adding the paths.length again) rather than the total counts. After all, calling watcher.add() for three times should yield the same readyCount as calling it one time with all 3 different paths.

I added a test for this fix. The test hangs forever on macOS because readyCount is too large. With the new fix, the ready event is emitted as expected.

JLHwung commented 1 year ago

The current CI errors seem to be unrelated, since they are breaking on the main branch as well.