Skip to content

Commit

Permalink
fix: do not report directory as initial missing on the second watch
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Mar 12, 2024
1 parent f5baba7 commit c708c45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ class DirectoryWatcher extends EventEmitter {
!this.directories.has(filePath) &&
watcher.checkStartTime(this.initialScanFinished, false)
) {
console.log(watcher.checkStartTime(this.initialScanFinished, false))

Check failure on line 368 in lib/DirectoryWatcher.js

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
process.nextTick(() => {
if (this.closed) return;
watcher.emit("initial-missing", "watch (missing on attach)");
Expand Down
23 changes: 23 additions & 0 deletions test/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,29 @@ describe("DirectoryWatcher", function() {
});
});

it("should not report directory as initial missing on the second watch", function(done) {
var wm = getWatcherManager({});
testHelper.dir("dir1");
wm.watchDirectory(path.join(fixtures, "dir1"));

testHelper.tick(function() {
var initialMissing = false;
wm.watchDirectory(path.join(fixtures, "dir1")).on(
"initial-missing",
() => {
initialMissing = true;
}
);
process.nextTick(() => {
for (const [, w] of wm.directoryWatchers) {
w.close();
}
initialMissing.should.be.eql(false);
done();
});
});
});

if (!+process.env.WATCHPACK_POLLING) {
it("should log errors emitted from watcher to stderr", function(done) {
var error_logged = false;
Expand Down

0 comments on commit c708c45

Please sign in to comment.