@@ -93,8 +93,7 @@ function load(settings, options, config, callback) {
9393 // if we didn't pick up a nodemon.json file & there's no cli ignores
9494 // then try loading an old style .nodemonignore file
9595 if ( config . loaded . length === 0 ) {
96- // TODO decide whether this is just confusing...
97- var legacy = loadLegacyIgnore . bind ( null , options , ready ) ;
96+ var legacy = loadLegacyIgnore . bind ( null , options , config , ready ) ;
9897
9998 // first try .nodemonignore, if that doesn't exist, try nodemon-ignore
10099 return legacy ( '.nodemonignore' , function ( ) {
@@ -118,11 +117,12 @@ function load(settings, options, config, callback) {
118117 * @param {String } filename ignore file (.nodemonignore or nodemon-ignore)
119118 * @param {Function } fail (optional) failure callback
120119 */
121- function loadLegacyIgnore ( options , success , filename , fail ) {
120+ function loadLegacyIgnore ( options , config , success , filename , fail ) {
122121 var ignoreFile = path . join ( process . cwd ( ) , filename ) ;
123122
124123 exists ( ignoreFile , function ( exists ) {
125124 if ( exists ) {
125+ config . loaded . push ( ignoreFile ) ;
126126 return parse ( ignoreFile , function ( error , rules ) {
127127 options . ignore = rules . raw ;
128128 success ( options ) ;
@@ -172,6 +172,12 @@ function loadFile(options, config, dir, ready) {
172172 }
173173
174174 var filename = options . configFile || path . join ( dir , 'nodemon.json' ) ;
175+
176+ if ( config . loaded . indexOf ( filename ) !== - 1 ) {
177+ // don't bother re-parsing the same config file
178+ return callback ( { } ) ;
179+ }
180+
175181 fs . readFile ( filename , 'utf8' , function ( err , data ) {
176182 if ( err ) {
177183 if ( err . code === 'ENOENT' ) {
@@ -188,7 +194,9 @@ function loadFile(options, config, dir, ready) {
188194
189195 try {
190196 settings = JSON . parse ( data . toString ( 'utf8' ) . replace ( / ^ \uFEFF / , '' ) ) ;
191- config . loaded . push ( filename ) ;
197+ if ( ! filename . endsWith ( 'package.json' ) || settings . nodemonConfig ) {
198+ config . loaded . push ( filename ) ;
199+ }
192200 } catch ( e ) {
193201 console . error ( e ) ;
194202 utils . log . fail ( 'Failed to parse config ' + filename ) ;
0 commit comments