Nodemon手表选项损坏

我正在使用gulp-nodemon

config目录只包含一个文件server.js。

$.nodemon({ script: 'config/server.js', watch: ['config/**/*.js'] }) .on('restart', function () { setTimeout(function () { $.livereload.changed(); }, 1000); }); 

输出:

 [gulp] [nodemon] v1.2.1 [gulp] [nodemon] to restart at any time, enter `rs` [gulp] [nodemon] watching: config/**/*.js [gulp] [nodemon] starting `node config/server.js` [gulp] [nodemon] watching 34,325 files - this might cause high cpu usage. To reduce use "--watch". 

如果我包括一个忽略选项它修复。

 ignore: [ 'node_modules/**', 'bower_components/**' ] 

为什么nodemon监视一切,即使我告诉它只能看config目录?

另外它从输出中只看到configuration目录[nodemon] watching: config/**/*.js

这似乎是nodemon本身的错误,因为我可以使用简单的nodemon命令重现它:

 > nodemon --watch app server.js [nodemon] v1.2.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching: app/**/* [nodemon] starting `node server.js` [nodemon] watching 72,981 files - this might cause high cpu usage. To reduce use "--watch" 

nodemon的默认行为是监视项目根目录中的所有目录,并忽略某些目录,如node_modulesbower_components.sass_cache 。 这个默认的ignore不起作用,但是在这个PR中被修复了。 应用此修复程序,我的输出与预期一致。

 > nodemon --watch app server.js [nodemon] v1.2.1 [nodemon] to restart at any time, enter `rs` [nodemon] watching: app/**/* [nodemon] starting `node server.js` 

我使用这两种configuration进行了testing,即使出现警告,我的nodemon也不会刷新指定的目录中的文件更改,而是像预期的那样工作,没有性能问题。 这更可能是对我的假阳性警告。

但现在我build议你留在你的ignore规则,直到这被合并到nodemon或另一个解决方法被发现。

这里有一些相关的问题: #46 , #366和#32