Skip to content

Instantly share code, notes, and snippets.

@amirkheirabadi73
Created July 2, 2013 06:28
Show Gist options
  • Save amirkheirabadi73/5907150 to your computer and use it in GitHub Desktop.
Save amirkheirabadi73/5907150 to your computer and use it in GitHub Desktop.
Watch A File For Changes RealTime
var fs = require("fs");
console.log("Read File ....");
var conf = JSON.parse(fs.readFileSync("config.json"));
console.log("One : ", conf);
fs.watchFile("config.json", function(current,previous){
console.log("File Changed ...");
var conf = JSON.parse(fs.readFileSync("config.json"));
console.log("Two : " , conf);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment