fs.watch( \'example.xml\', function ( curr, prev ) {
// on file change we can read the new xml
fs.readFile( \'example.xml\',\'utf8\', function ( err, data ) {
I somtimes get multible registrations of the Watch event causing the Watch event to fire several times. I solved it by keeping a list of watching files and avoid registering the event if the file allready is in the list:
var watchfiles = {};
function initwatch(fn, callback) {
if watchlist[fn] {
watchlist[fn] = true;
fs.watch(fn).on('change', callback);
}
}
......