diff --git a/lib/monitor/watch.js b/lib/monitor/watch.js index 68220b54..09c334df 100644 --- a/lib/monitor/watch.js +++ b/lib/monitor/watch.js @@ -24,7 +24,6 @@ function resetWatchers() { watchers = []; } - function watch() { if (watchers.length) { debug('early exit on watch, still watching (%s)', watchers.length); @@ -141,6 +140,22 @@ function filterAndRestart(files) { undefsafe(config, 'options.execOptions.ext') ); + // 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, + } + return true; + } + }) + } + utils.log.detail('changes after filters (before/after): ' + [files.length, matched.result.length].join('/'));