* Returns a compiler watcher. * @param {WatchOptions | WatchOptions[]} watchOptions the watcher's options * @param {Callback<MultiStats>} handler signals when the call finishes * @returns {MultiWatching | undefined} a compiler watcher
(watchOptions, handler)
| 636 | * @returns {MultiWatching | undefined} a compiler watcher |
| 637 | */ |
| 638 | watch(watchOptions, handler) { |
| 639 | if (this.running) { |
| 640 | handler(new ConcurrentCompilationError()); |
| 641 | return; |
| 642 | } |
| 643 | this.running = true; |
| 644 | |
| 645 | if (this.validateDependencies(handler)) { |
| 646 | const watchings = this._runGraph( |
| 647 | (compiler, idx, callback, isBlocked, setChanged, setInvalid) => { |
| 648 | const watching = compiler.watch( |
| 649 | Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions, |
| 650 | callback |
| 651 | ); |
| 652 | if (watching) { |
| 653 | watching._onInvalid = setInvalid; |
| 654 | watching._onChange = setChanged; |
| 655 | watching._isBlocked = isBlocked; |
| 656 | } |
| 657 | return watching; |
| 658 | }, |
| 659 | (compiler, watching, _callback) => { |
| 660 | if (compiler.watching !== watching) return; |
| 661 | if (!watching.running) watching.invalidate(); |
| 662 | }, |
| 663 | handler |
| 664 | ); |
| 665 | return new MultiWatching(watchings, this); |
| 666 | } |
| 667 | |
| 668 | return new MultiWatching([], this); |
| 669 | } |
| 670 | |
| 671 | /** |
| 672 | * Processes the provided multi stat. |
nothing calls this directly
no test coverage detected