watch-files.js 838 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. var fs = require('fs-extra');
  4. var path = require('path');
  5. var watch = require('watch');
  6. // Handle a change to a file.
  7. function handleFile(filename) {
  8. var name = path.basename(filename);
  9. var parts = filename.split(path.sep);
  10. parts[0] = '..';
  11. parts[2] = 'lib';
  12. target = path.resolve(parts.join(path.sep));
  13. fs.copySync(filename, target);
  14. }
  15. // Watch the files in lib.
  16. watch.createMonitor('lib', function (monitor) {
  17. monitor.on("created", function (f, curr, prev) {
  18. watch.createMonitor(f, function (submonitor) {
  19. submonitor.on("changed", handleFile);
  20. });
  21. });
  22. monitor.on("changed", handleFile);
  23. // Handle the initial files.
  24. require('./build');
  25. console.log('Watching the metapackage files...');
  26. });