项目原始demo,不改动
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

33 lines
701 B

  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("async");
  7. class MultiWatching {
  8. constructor(watchings, compiler) {
  9. this.watchings = watchings;
  10. this.compiler = compiler;
  11. }
  12. invalidate() {
  13. this.watchings.forEach((watching) => watching.invalidate());
  14. }
  15. close(callback) {
  16. if(callback === undefined) callback = () => { /*do nothing*/ };
  17. asyncLib.forEach(this.watchings, (watching, finishedCallback) => {
  18. watching.close(finishedCallback);
  19. }, err => {
  20. this.compiler.applyPlugins("watch-close");
  21. callback(err);
  22. });
  23. }
  24. }
  25. module.exports = MultiWatching;