Skip to content

Commit 718a9ad

Browse files
committedJan 8, 2018
fix: correctly pass ignored rules to chokidar
Previous the rules weren't matching fully inside of chokidar, requiring that, for instance, node_modules is written as **/node_modules/**. I've also tidied up what's printed in verbose mode, so it doesn't print default ignores, and doesn't print the full path of an ignored directory. This change _also_ fixes notifications from chokidar from user ignored paths (using the `cwd` argument). This should fix #1202
1 parent 64a82ff commit 718a9ad

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed
 

‎lib/config/defaults.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
// compatible with linux, mac and windows, or make the default.js
1212
// dynamically append the `.cmd` for node based utilities
1313
},
14-
ignoreRoot: ignoreRoot.map(_ => `**/${_}`),
14+
ignoreRoot: ignoreRoot.map(_ => `**/${_}/**`),
1515
watch: ['*.*'],
1616
stdin: true,
1717
runOnChangeOnly: false,

‎lib/monitor/match.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ function rulesToMonitor(watch, ignore, config) {
8989
if (rule.slice(-4) !== '**/*' &&
9090
rule.slice(-1) === '*' &&
9191
rule.indexOf('*.') === -1) {
92-
rule += '*/*';
92+
93+
if (rule.slice(-2) !== '**') rule += '*/*';
9394
}
9495

9596

‎lib/monitor/watch.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function watch() {
4949
}
5050

5151
var watchOptions = {
52+
cwd: process.cwd(), // use cwd for relative path ignore
5253
ignored: ignored,
5354
persistent: true,
5455
usePolling: config.options.legacyWatch || false,

‎lib/nodemon.js

+24-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var bus = utils.bus;
99
var help = require('./help');
1010
var config = require('./config');
1111
var spawn = require('./spawn');
12+
const defaults = require('./config/defaults')
1213
var eventHandlers = {};
1314

1415
// this is fairly dirty, but theoretically sound since it's part of the
@@ -65,6 +66,8 @@ function nodemon(settings) {
6566
}
6667
}
6768

69+
const cwd = process.cwd();
70+
6871
config.load(settings, function (config) {
6972
if (!config.options.dump && !config.options.execOptions.script &&
7073
config.options.execOptions.exec === 'node') {
@@ -147,9 +150,26 @@ function nodemon(settings) {
147150
restartSignal + ' to ' + process.pid + ' to restart');
148151
}
149152

150-
utils.log.detail('ignoring: ' + config.options.monitor.map(function (rule) {
151-
return rule.slice(0, 1) === '!' ? rule.slice(1) : false;
152-
}).filter(Boolean).join(' '));
153+
const ignoring = config.options.monitor.map(function (rule) {
154+
if (rule.slice(0, 1) !== '!') {
155+
return false;
156+
}
157+
158+
rule = rule.slice(1);
159+
160+
// don't notify of default ignores
161+
if (defaults.ignoreRoot.includes(rule)) {
162+
return false;
163+
return rule.slice(3).slice(0, -3);
164+
}
165+
166+
if (rule.startsWith(cwd)) {
167+
return rule.replace(cwd, '.');
168+
}
169+
170+
return rule;
171+
}).filter(Boolean).join(' ');
172+
if (ignoring) utils.log.detail('ignoring: ' + ignoring);
153173

154174
utils.log.info('watching: ' + config.options.monitor.map(function (rule) {
155175
return rule.slice(0, 1) !== '!' ? rule : false;
@@ -162,7 +182,7 @@ function nodemon(settings) {
162182
utils.log._log('log', 'node: ' + process.version);
163183
utils.log._log('log', 'nodemon: ' + version.pinned);
164184
utils.log._log('log', 'command: ' + process.argv.join(' '));
165-
utils.log._log('log', 'cwd: ' + process.cwd());
185+
utils.log._log('log', 'cwd: ' + cwd);
166186
utils.log._log('log', ['OS:', process.platform, process.arch].join(' '));
167187
utils.log._log('log', '--------------');
168188
utils.log._log('log', util.inspect(config, { depth: null }));

0 commit comments

Comments
 (0)