auto.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. // var watch = require('watch');
  2. // watch.watchTree("../unity2laya", (f, curr, prev) => {
  3. // if (typeof f == "object" && prev === null && curr === null) {
  4. // console.log("Finished walking the tree");
  5. // } else if (prev === null) {
  6. // console.log("f is a new file");
  7. // } else if (curr.nlink === 0) {
  8. // // f was removed
  9. // console.log("f was removed");
  10. // } else {
  11. // console.log("f was changed");
  12. // }
  13. // })
  14. var watch = require('watch');
  15. watch.createMonitor('../unity2laya', function (monitor) {
  16. // monitor.files['/home/mikeal/.zshrc'] // Stat object for my zshrc.
  17. monitor.on("created", function (f, stat) {
  18. // Handle new files
  19. console.log("Handle new files");
  20. })
  21. monitor.on("changed", function (f, curr, prev) {
  22. // Handle file changes
  23. console.log(f,curr,prev);
  24. })
  25. monitor.on("removed", function (f, stat) {
  26. console.log("Handle removed files");
  27. // Handle removed files
  28. })
  29. //monitor.stop(); // Stop watching
  30. });