Skip to content

Commit af3422c

Browse files
committed
Add callback to Watching.prototype.invalidate
1 parent 9c5c6df commit af3422c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/Compiler.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function Watching(compiler, watchOptions, handler) {
1818
this.error = null;
1919
this.stats = null;
2020
this.handler = handler;
21+
this.callbacks = [];
2122
if(typeof watchOptions === "number") {
2223
this.watchOptions = {
2324
aggregateTimeout: watchOptions
@@ -95,6 +96,10 @@ Watching.prototype._done = function(err, compilation) {
9596
this.handler(this.error, this.stats);
9697
if(!this.error)
9798
this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
99+
this.callbacks.forEach(function(cb) {
100+
cb();
101+
});
102+
this.callbacks.length = 0;
98103
};
99104

100105
Watching.prototype.watch = function(files, dirs, missing) {
@@ -110,7 +115,10 @@ Watching.prototype.watch = function(files, dirs, missing) {
110115
}.bind(this));
111116
};
112117

113-
Watching.prototype.invalidate = function() {
118+
Watching.prototype.invalidate = function(callback) {
119+
if(callback) {
120+
this.callbacks.push(callback);
121+
}
114122
if(this.watcher) {
115123
this.watcher.pause();
116124
this.watcher = null;

0 commit comments

Comments
 (0)