UI for Zipcoin Blue

WatchIgnorePlugin.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class WatchIgnorePlugin {
  7. constructor(paths) {
  8. this.paths = paths;
  9. }
  10. apply(compiler) {
  11. compiler.plugin("after-environment", () => {
  12. compiler.watchFileSystem = new IgnoringWatchFileSystem(compiler.watchFileSystem, this.paths);
  13. });
  14. }
  15. }
  16. module.exports = WatchIgnorePlugin;
  17. class IgnoringWatchFileSystem {
  18. constructor(wfs, paths) {
  19. this.wfs = wfs;
  20. this.paths = paths;
  21. }
  22. watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
  23. const ignored = path => this.paths.some(p => p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0);
  24. const notIgnored = path => !ignored(path);
  25. const ignoredFiles = files.filter(ignored);
  26. const ignoredDirs = dirs.filter(ignored);
  27. this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => {
  28. if(err) return callback(err);
  29. ignoredFiles.forEach(path => {
  30. fileTimestamps[path] = 1;
  31. });
  32. ignoredDirs.forEach(path => {
  33. dirTimestamps[path] = 1;
  34. });
  35. callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps);
  36. }, callbackUndelayed);
  37. }
  38. }