You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
886 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const asyncLib = require("neo-async");
  7. class MultiWatching {
  8. constructor(watchings, compiler) {
  9. this.watchings = watchings;
  10. this.compiler = compiler;
  11. }
  12. invalidate() {
  13. for (const watching of this.watchings) {
  14. watching.invalidate();
  15. }
  16. }
  17. suspend() {
  18. for (const watching of this.watchings) {
  19. watching.suspend();
  20. }
  21. }
  22. resume() {
  23. for (const watching of this.watchings) {
  24. watching.resume();
  25. }
  26. }
  27. close(callback) {
  28. asyncLib.forEach(
  29. this.watchings,
  30. (watching, finishedCallback) => {
  31. watching.close(finishedCallback);
  32. },
  33. err => {
  34. this.compiler.hooks.watchClose.call();
  35. if (typeof callback === "function") {
  36. this.compiler.running = false;
  37. callback(err);
  38. }
  39. }
  40. );
  41. }
  42. }
  43. module.exports = MultiWatching;