UNPKG

714 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7const asyncLib = require("neo-async");
8
9class 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
38module.exports = MultiWatching;