diff --git a/lib/monitor/watch.js b/lib/monitor/watch.js index 09c334df..481f8259 100644 --- a/lib/monitor/watch.js +++ b/lib/monitor/watch.js @@ -142,18 +142,20 @@ function filterAndRestart(files) { // if there's no matches, then test to see if the changed file is the // running script, if so, let's allow a restart - const script = path.resolve(config.options.execOptions.script); - if (matched.result.length === 0 && script) { - const length = script.length; - files.find(file => { - if (file.substr(-length, length) === script) { - matched = { - result: [ file ], - total: 1, + if (config.options.execOptions.script) { + const script = path.resolve(config.options.execOptions.script); + if (matched.result.length === 0 && script) { + const length = script.length; + files.find(file => { + if (file.substr(-length, length) === script) { + matched = { + result: [ file ], + total: 1, + } + return true; } - return true; - } - }) + }) + } } utils.log.detail('changes after filters (before/after): ' +