Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/DirectoryWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class DirectoryWatcher extends EventEmitter {
this.forEachWatcher(itemPath, w => w.emit("remove", type));
if (!initial) {
this.forEachWatcher(this.path, w =>
w.emit("change", itemPath, null, type)
w.emit("change", itemPath, null, type, initial)
);
}
}
Expand All @@ -167,7 +167,7 @@ class DirectoryWatcher extends EventEmitter {

if (!initial) {
this.forEachWatcher(this.path, w =>
w.emit("change", itemPath, null, type)
w.emit("change", itemPath, null, type, initial)
);
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ class DirectoryWatcher extends EventEmitter {
}
this.forEachWatcher(this.path, w => {
if (!initial || w.checkStartTime(safeTime, initial)) {
w.emit("change", filePath, safeTime, type);
w.emit("change", filePath, safeTime, type, initial);
}
});
}
Expand All @@ -239,7 +239,7 @@ class DirectoryWatcher extends EventEmitter {
if (directoryPath === this.path) {
if (!initial) {
this.forEachWatcher(this.path, w =>
w.emit("change", directoryPath, mtime, type)
w.emit("change", directoryPath, mtime, type, initial)
);
}
} else {
Expand Down Expand Up @@ -268,7 +268,7 @@ class DirectoryWatcher extends EventEmitter {
});
this.forEachWatcher(this.path, w => {
if (!initial || w.checkStartTime(safeTime, initial)) {
w.emit("change", directoryPath, safeTime, type);
w.emit("change", directoryPath, safeTime, type, initial);
}
});
}
Expand All @@ -277,11 +277,11 @@ class DirectoryWatcher extends EventEmitter {

createNestedWatcher(directoryPath) {
const watcher = this.watcherManager.watchDirectory(directoryPath, 1);
watcher.on("change", (filePath, mtime, type) => {
watcher.on("change", (filePath, mtime, type, initial) => {
this._cachedTimeInfoEntries = undefined;
this.forEachWatcher(this.path, w => {
if (w.checkStartTime(mtime, false)) {
w.emit("change", filePath, mtime, type);
if (!initial || w.checkStartTime(mtime, initial)) {
w.emit("change", filePath, mtime, type, initial);
}
});
});
Expand Down Expand Up @@ -505,7 +505,7 @@ class DirectoryWatcher extends EventEmitter {

// directory was created so we emit an event
this.forEachWatcher(this.path, w =>
w.emit("change", this.path, mtime, type)
w.emit("change", this.path, mtime, type, false)
);
}
});
Expand Down
27 changes: 27 additions & 0 deletions test/Watchpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,33 @@ describe("Watchpack", function() {
});
});

it("should not report changes in initial scan when no start time is provided", function(done) {
var w = new Watchpack({
aggregateTimeout: 1000
});
w.on("aggregated", () => {
done(new Error("should not fire"));
});
testHelper.dir("dir");
testHelper.dir("dir/b");
testHelper.dir("dir/b/sub");
testHelper.file("dir/b/sub/file");
testHelper.file("dir/b/file");
testHelper.file("dir/a");
testHelper.tick(() => {
w.watch({
files: [path.join(fixtures, "dir", "a")],
directories: [path.join(fixtures, "dir", "b")],
missing: [path.join(fixtures, "dir", "c")]
});
testHelper.tick(2000, () => {
// no event fired
w.close();
done();
});
});
});

it("should report removal of file and directory if it is missing in initial scan", function(done) {
var w = new Watchpack({
aggregateTimeout: 1000
Expand Down