From bfdd045c94b4bb5d25f32fbcdc23795f8068be51 Mon Sep 17 00:00:00 2001 From: remy Date: Sun, 3 Oct 2010 17:04:27 +0100 Subject: [PATCH 1/2] Updated to dynamic reload the ignore list if the ignore file changes --- nodemon | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nodemon b/nodemon index 9ddbc88..a3240ed 100755 --- a/nodemon +++ b/nodemon @@ -76,15 +76,23 @@ function startMonitor() { }); } -require('path').exists(ignoreFilePath, function () { +function readIgnoreFile() { + sys.log('[nodemon] reading ignore list'); var lines = fs.readFileSync(ignoreFilePath).toString().split(/\n/); + ignoreFiles = [flag]; lines.forEach(function (line) { // remove comments and trim lines line = line.replace(/#.*$/, '').replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, ''); if (line) { ignoreFiles.push(line); } - }); + }); +} + +require('path').exists(ignoreFilePath, function () { + readIgnoreFile(); + // monitor the ignore file for any changes and reload the script if it does change + fs.watchFile(ignoreFilePath, { persistent: false }, readIgnoreFile); }); // touch From d00d1af5bb7e1997c569bff45d95f7b04058fa56 Mon Sep 17 00:00:00 2001 From: remy Date: Sun, 3 Oct 2010 17:10:00 +0100 Subject: [PATCH 2/2] Fixed the monitoring of the ignore - it removes and resets the watch now --- nodemon | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nodemon b/nodemon index a3240ed..677b463 100755 --- a/nodemon +++ b/nodemon @@ -77,6 +77,7 @@ function startMonitor() { } function readIgnoreFile() { + fs.unwatchFile(ignoreFilePath); sys.log('[nodemon] reading ignore list'); var lines = fs.readFileSync(ignoreFilePath).toString().split(/\n/); ignoreFiles = [flag]; @@ -87,13 +88,10 @@ function readIgnoreFile() { ignoreFiles.push(line); } }); + fs.watchFile(ignoreFilePath, { persistent: false }, readIgnoreFile); } -require('path').exists(ignoreFilePath, function () { - readIgnoreFile(); - // monitor the ignore file for any changes and reload the script if it does change - fs.watchFile(ignoreFilePath, { persistent: false }, readIgnoreFile); -}); +require('path').exists(ignoreFilePath, readIgnoreFile); // touch fs.writeFileSync(flag, '');