From 0f6ae5ca27bee94ea79cebbe566117bbe216cc54 Mon Sep 17 00:00:00 2001 From: Phred Date: Sun, 3 Oct 2010 09:08:46 -0700 Subject: [PATCH] prevent unnecessary looping --- nodemon | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nodemon b/nodemon index 93dd1ce..ab01785 100644 --- a/nodemon +++ b/nodemon @@ -41,17 +41,20 @@ function startMonitor() { var cmd = 'find . -newer ' + flag + ' -print;'; exec(cmd, function (error, stdout, stderr) { - var files = stdout.split(/\n/), finalFiles; + var files = stdout.split(/\n/); files.pop(); // remove blank line ending and split if (files.length) { - finalFiles = files.filter(function(file) { - return !reIgnoreFiles.test(file); - }); + // filter ignored files + if (ignoreFiles.length) { + files = files.filter(function(file) { + return !reIgnoreFiles.test(file); + }); + } fs.writeFileSync(flag, ''); - if (finalFiles.length) { + if (files.length) { sys.log('[nodemon] restarting due to changes...'); finalFiles.forEach(function (file) { sys.log('[nodemon] ' + file);