Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var fs = require("fs");
  2. var spawn = require("child_process").spawn;
  3. fileName = process.argv[2];
  4.  
  5. if(!fileName)
  6. {
  7.   fileName = "fileio.js";
  8.  
  9. }
  10.  
  11. function watchCallback(fileName)
  12. {
  13.     let cmd = spawn("cmd.exe", ["/c", fileName]);
  14.     cmd.stdout.pipe(process.stdout);
  15.     console.log("file " + fileName + "just changed");
  16. }
  17.  
  18. fs.watch(fileName, watchCallback(fileName));
  19. console.log("watching for changes");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement