diff --git a/lib/config/defaults.js b/lib/config/defaults.js index 092da50e..6a225619 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -11,7 +11,7 @@ module.exports = { // compatible with linux, mac and windows, or make the default.js // dynamically append the `.cmd` for node based utilities }, - ignoreRoot: ignoreRoot.map(_ => `**/${_}`), + ignoreRoot: ignoreRoot.map(_ => `**/${_}/**`), watch: ['*.*'], stdin: true, runOnChangeOnly: false, diff --git a/lib/monitor/match.js b/lib/monitor/match.js index 9ae1c820..7b6d7758 100644 --- a/lib/monitor/match.js +++ b/lib/monitor/match.js @@ -89,7 +89,8 @@ function rulesToMonitor(watch, ignore, config) { if (rule.slice(-4) !== '**/*' && rule.slice(-1) === '*' && rule.indexOf('*.') === -1) { - rule += '*/*'; + + if (rule.slice(-2) !== '**') rule += '*/*'; } diff --git a/lib/monitor/watch.js b/lib/monitor/watch.js index 7becd47c..1d9cccc0 100644 --- a/lib/monitor/watch.js +++ b/lib/monitor/watch.js @@ -49,6 +49,7 @@ function watch() { } var watchOptions = { + cwd: process.cwd(), // use cwd for relative path ignore ignored: ignored, persistent: true, usePolling: config.options.legacyWatch || false, diff --git a/lib/nodemon.js b/lib/nodemon.js index 1bd24786..ed12ed9b 100644 --- a/lib/nodemon.js +++ b/lib/nodemon.js @@ -9,6 +9,7 @@ var bus = utils.bus; var help = require('./help'); var config = require('./config'); var spawn = require('./spawn'); +const defaults = require('./config/defaults') var eventHandlers = {}; // this is fairly dirty, but theoretically sound since it's part of the @@ -65,6 +66,8 @@ function nodemon(settings) { } } + const cwd = process.cwd(); + config.load(settings, function (config) { if (!config.options.dump && !config.options.execOptions.script && config.options.execOptions.exec === 'node') { @@ -147,9 +150,26 @@ function nodemon(settings) { restartSignal + ' to ' + process.pid + ' to restart'); } - utils.log.detail('ignoring: ' + config.options.monitor.map(function (rule) { - return rule.slice(0, 1) === '!' ? rule.slice(1) : false; - }).filter(Boolean).join(' ')); + const ignoring = config.options.monitor.map(function (rule) { + if (rule.slice(0, 1) !== '!') { + return false; + } + + rule = rule.slice(1); + + // don't notify of default ignores + if (defaults.ignoreRoot.includes(rule)) { + return false; + return rule.slice(3).slice(0, -3); + } + + if (rule.startsWith(cwd)) { + return rule.replace(cwd, '.'); + } + + return rule; + }).filter(Boolean).join(' '); + if (ignoring) utils.log.detail('ignoring: ' + ignoring); utils.log.info('watching: ' + config.options.monitor.map(function (rule) { return rule.slice(0, 1) !== '!' ? rule : false; @@ -162,7 +182,7 @@ function nodemon(settings) { utils.log._log('log', 'node: ' + process.version); utils.log._log('log', 'nodemon: ' + version.pinned); utils.log._log('log', 'command: ' + process.argv.join(' ')); - utils.log._log('log', 'cwd: ' + process.cwd()); + utils.log._log('log', 'cwd: ' + cwd); utils.log._log('log', ['OS:', process.platform, process.arch].join(' ')); utils.log._log('log', '--------------'); utils.log._log('log', util.inspect(config, { depth: null }));