webpack/lib/MultiWatching.js

34 lines
652 B
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
2017-04-05 21:06:23 +08:00
const asyncLib = require("async");
class MultiWatching {
constructor(watchings, compiler) {
this.watchings = watchings;
this.compiler = compiler;
}
invalidate() {
2018-01-22 20:52:43 +08:00
for(const watching of this.watchings) {
watching.invalidate();
}
}
close(callback) {
2017-04-05 21:06:23 +08:00
asyncLib.forEach(this.watchings, (watching, finishedCallback) => {
watching.close(finishedCallback);
}, err => {
2017-11-28 22:01:41 +08:00
this.compiler.hooks.watchClose.call();
2018-01-22 20:52:43 +08:00
if(typeof callback === "function") {
callback(err);
}
});
}
}
module.exports = MultiWatching;