Skip to content

Commit 1370123

Browse files
committed
fix readyCount logic
1 parent 08318d6 commit 1370123

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ add(paths_, _origAdd, _internal) {
441441

442442
if (this.options.useFsEvents && this._fsEventsHandler) {
443443
if (!this._readyCount) this._readyCount = paths.length;
444-
if (this.options.persistent) this._readyCount *= 2;
444+
if (this.options.persistent) this._readyCount += paths.length;
445445
paths.forEach((path) => this._fsEventsHandler._addToFsEvents(path));
446446
} else {
447447
if (!this._readyCount) this._readyCount = 0;

test.js

+11
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@ const runTests = (baseopts) => {
469469
unlinkSpy.withArgs(newPath1).should.have.been.calledOnce;
470470
unlinkSpy.withArgs(newPath2).should.not.have.been.called;
471471
});
472+
it('should emit `ready` when three files were added', async () => {
473+
const path1 = getFixturePath('add1.txt');
474+
const path2 = getFixturePath('add2.txt');
475+
const path3 = getFixturePath('add3.txt');
476+
477+
watcher.add(path1);
478+
watcher.add(path2);
479+
watcher.add(path3);
480+
481+
await waitForWatcher(watcher);
482+
});
472483
it('should survive ENOENT for missing subdirectories', async () => {
473484
const testDir = getFixturePath('notadir');
474485
await waitForWatcher(watcher);

0 commit comments

Comments
 (0)