main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | const asyncLib = require("neo-async");
|
---|
| 9 |
|
---|
| 10 | /** @typedef {import("./MultiCompiler")} MultiCompiler */
|
---|
| 11 | /** @typedef {import("./Watching")} Watching */
|
---|
| 12 |
|
---|
| 13 | /**
|
---|
| 14 | * @template T
|
---|
| 15 | * @callback Callback
|
---|
| 16 | * @param {(Error | null)=} err
|
---|
| 17 | * @param {T=} result
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | class MultiWatching {
|
---|
| 21 | /**
|
---|
| 22 | * @param {Watching[]} watchings child compilers' watchers
|
---|
| 23 | * @param {MultiCompiler} compiler the compiler
|
---|
| 24 | */
|
---|
| 25 | constructor(watchings, compiler) {
|
---|
| 26 | this.watchings = watchings;
|
---|
| 27 | this.compiler = compiler;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | /**
|
---|
| 31 | * @param {Callback<void>=} callback signals when the build has completed again
|
---|
| 32 | * @returns {void}
|
---|
| 33 | */
|
---|
| 34 | invalidate(callback) {
|
---|
| 35 | if (callback) {
|
---|
| 36 | asyncLib.each(
|
---|
| 37 | this.watchings,
|
---|
| 38 | (watching, callback) => watching.invalidate(callback),
|
---|
| 39 | callback
|
---|
| 40 | );
|
---|
| 41 | } else {
|
---|
| 42 | for (const watching of this.watchings) {
|
---|
| 43 | watching.invalidate();
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | suspend() {
|
---|
| 49 | for (const watching of this.watchings) {
|
---|
| 50 | watching.suspend();
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | resume() {
|
---|
| 55 | for (const watching of this.watchings) {
|
---|
| 56 | watching.resume();
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * @param {Callback<void>} callback signals when the watcher is closed
|
---|
| 62 | * @returns {void}
|
---|
| 63 | */
|
---|
| 64 | close(callback) {
|
---|
| 65 | asyncLib.each(
|
---|
| 66 | this.watchings,
|
---|
| 67 | (watching, finishedCallback) => {
|
---|
| 68 | watching.close(finishedCallback);
|
---|
| 69 | },
|
---|
| 70 | err => {
|
---|
| 71 | this.compiler.hooks.watchClose.call();
|
---|
| 72 | if (typeof callback === "function") {
|
---|
| 73 | this.compiler.running = false;
|
---|
| 74 | callback(err);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | );
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | module.exports = MultiWatching;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.