Skip to content

Commit 44e02f4

Browse files
committed
Wrap callback in watcher's close method
1 parent 60a5edc commit 44e02f4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/Watching.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,12 @@ class Watching {
166166
}
167167

168168
close(callback) {
169-
if (callback === undefined) callback = () => {};
169+
const finalCallback = () => {
170+
this.compiler.hooks.watchClose.call();
171+
this.compiler.running = false;
172+
if (callback !== undefined) callback();
173+
};
170174

171-
this.compiler.running = false;
172175
this.closed = true;
173176
if (this.watcher) {
174177
this.watcher.close();
@@ -180,13 +183,9 @@ class Watching {
180183
}
181184
if (this.running) {
182185
this.invalid = true;
183-
this._done = () => {
184-
this.compiler.hooks.watchClose.call();
185-
callback();
186-
};
186+
this._done = finalCallback;
187187
} else {
188-
this.compiler.hooks.watchClose.call();
189-
callback();
188+
finalCallback();
190189
}
191190
}
192191
}

0 commit comments

Comments
 (0)