martijn
/
hugo-gopher
Archived
1
0
Fork 0

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
1 changed files with 7 additions and 0 deletions

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 ) {