Skip to content

Commit e6e0b75

Browse files
committed
added Watching.close
fixed webpack#249
1 parent fd11d59 commit e6e0b75

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

‎lib/Compiler.js‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ Watching.prototype.watch = function(files, dirs) {
9393
};
9494

9595
Watching.prototype.invalidate = function() {
96-
if(this.watcher) this.watcher.close();
96+
if(this.watcher) {
97+
this.watcher.close();
98+
this.watcher = null;
99+
}
97100
if(this.running) {
98101
this.invalid = true;
99102
return false;
@@ -102,6 +105,21 @@ Watching.prototype.invalidate = function() {
102105
}
103106
};
104107

108+
Watching.prototype.close = function(callback) {
109+
if(this.watcher) {
110+
this.watcher.close();
111+
this.watcher = null;
112+
}
113+
if(this.running) {
114+
this.invalid = true;
115+
this._done = function() {
116+
callback();
117+
};
118+
} else {
119+
callback();
120+
}
121+
};
122+
105123
function Compiler() {
106124
Tapable.call(this);
107125
this.mainTemplate = this.chunkTemplate = this.moduleTemplate = null;

0 commit comments

Comments
 (0)