MultiWatching.js 714 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. close(callback) {
  18. asyncLib.forEach(
  19. this.watchings,
  20. (watching, finishedCallback) => {
  21. watching.close(finishedCallback);
  22. },
  23. err => {
  24. this.compiler.hooks.watchClose.call();
  25. if (typeof callback === "function") {
  26. this.compiler.running = false;
  27. callback(err);
  28. }
  29. }
  30. );
  31. }
  32. }
  33. module.exports = MultiWatching;