add getContext/FileTimestamps to watcher

get timestamps on invalidate

fixes #5970
This commit is contained in:
Tobias Koppers 2018-01-03 12:48:46 +01:00
parent e9f1ad208b
commit 74a8c45ea1
3 changed files with 41 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class IgnoringWatchFileSystem {
const ignoredFiles = files.filter(ignored);
const ignoredDirs = dirs.filter(ignored);
this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => {
const watcher = this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => {
if(err) return callback(err);
ignoredFiles.forEach(path => {
@ -49,5 +49,24 @@ class IgnoringWatchFileSystem {
callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps);
}, callbackUndelayed);
return {
close: () => watcher.close(),
pause: () => watcher.pause(),
getContextTimestamps: () => {
const dirTimestamps = watcher.getContextTimestamps();
ignoredDirs.forEach(path => {
dirTimestamps[path] = 1;
});
return dirTimestamps;
},
getFileTimestamps: () => {
const fileTimestamps = watcher.getFileTimestamps();
ignoredFiles.forEach(path => {
fileTimestamps[path] = 1;
});
return fileTimestamps;
}
};
}
}

View File

@ -111,7 +111,7 @@ class Watching {
this.compiler.fileTimestamps = fileTimestamps;
this.compiler.contextTimestamps = contextTimestamps;
this.invalidate();
this._invalidate();
}, (fileName, changeTime) => {
this.compiler.hooks.invalid.call(fileName, changeTime);
});
@ -121,6 +121,14 @@ class Watching {
if(callback) {
this.callbacks.push(callback);
}
if(this.watcher) {
this.compiler.fileTimestamps = this.watcher.getFileTimestamps();
this.compiler.contextTimestamps = this.watcher.getContextTimestamps();
}
return this._invalidate();
}
_invalidate() {
if(this.watcher) {
this.pausedWatcher = this.watcher;
this.watcher.pause();

View File

@ -64,6 +64,18 @@ class NodeWatchFileSystem {
if(this.watcher) {
this.watcher.pause();
}
},
getFileTimestamps: () => {
if(this.watcher)
return this.watcher.getTimes();
else
return {};
},
getContextTimestamps: () => {
if(this.watcher)
return this.watcher.getTimes();
else
return {};
}
};
}