Watch JSON file for changes
This commit is contained in:
parent
8fb8415e0a
commit
ecb2d04eca
1 changed files with 7 additions and 0 deletions
7
app.js
7
app.js
|
@ -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 ) {
|
||||
|
|
Reference in a new issue