self-reload-json
Version:
Self reloading JSON handler
18 lines (17 loc) • 436 B
JavaScript
(() => {
const SelfReloadJSON = require('./lib/');
const watchFile = new SelfReloadJSON({
fileName: './test.json',
additive: false,
delay: 500
});
watchFile.on('updated', () => {
console.log('File Updated:', watchFile);
setTimeout(() => {
watchFile.save();
}, 100);
})
watchFile.on('error', (err) => {
console.log('Error while refreshing:', err.message || err);
})
})();