1
Fork 0

include isNew in + events

This commit is contained in:
Conduitry 2018-04-03 21:25:20 -04:00
parent 64612f7107
commit 1dd3cb4238
1 changed files with 3 additions and 2 deletions

View File

@ -131,15 +131,16 @@ export default class CheapWatch extends EventEmitter {
if (this.filter && !await this.filter({ path, stats })) {
continue;
}
const isNew = !this.paths.has(path);
this.paths.set(path, stats);
this.emit('+', { path, stats });
this.emit('+', { path, stats, isNew });
if (stats.isDirectory() && !this[_watchers].has(path)) {
// note the new directory
// start watching it, and report any files in it
await this[_recurse](full);
for (const [newPath, stats] of this.paths.entries()) {
if (newPath.startsWith(path + '/')) {
this.emit('+', { path: newPath, stats });
this.emit('+', { path: newPath, stats, isNew: true });
}
}
}