1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 | const asyncLib = require("neo-async");
|
8 |
|
9 | class MultiWatching {
|
10 | constructor(watchings, compiler) {
|
11 | this.watchings = watchings;
|
12 | this.compiler = compiler;
|
13 | }
|
14 |
|
15 | invalidate() {
|
16 | for (const watching of this.watchings) {
|
17 | watching.invalidate();
|
18 | }
|
19 | }
|
20 |
|
21 | close(callback) {
|
22 | asyncLib.forEach(
|
23 | this.watchings,
|
24 | (watching, finishedCallback) => {
|
25 | watching.close(finishedCallback);
|
26 | },
|
27 | err => {
|
28 | this.compiler.hooks.watchClose.call();
|
29 | if (typeof callback === "function") {
|
30 | this.compiler.running = false;
|
31 | callback(err);
|
32 | }
|
33 | }
|
34 | );
|
35 | }
|
36 | }
|
37 |
|
38 | module.exports = MultiWatching;
|