Watch JSON file for changes

This commit is contained in:
Martijn de Boer 2019-01-05 20:36:49 +01:00
parent 8fb8415e0a
commit ecb2d04eca

7
app.js
View file

@ -17,6 +17,13 @@ var hugoJson = null;
loadJson();
fs.watch( config.jsonPath, function( ev, filename ) {
if ( filename ) {
console.log( 'JSON File has been updated and will be reloaded' );
loadJson();
}
} );
function loadJson() {
fs.readFile( config.jsonPath, 'utf8', function( err, data ) {
if ( err ) {