@@ -135,21 +135,23 @@ function nodemon(settings) {
135135 config . options . restartable + '`' ) ;
136136 }
137137
138- var none = function ( v ) {
139- return v ;
140- } ;
138+ if ( ! config . required ) {
139+ const restartSignal = config . options . signal === 'SIGUSR2' ? 'SIGHUP' : 'SIGUSR2' ;
140+ process . on ( restartSignal , nodemon . restart ) ;
141+ utils . log . detail ( ( config . options . restartable ? 'or ' : '' ) + 'send ' +
142+ restartSignal + ' to ' + process . pid + ' to restart' ) ;
143+ }
141144
142145 utils . log . detail ( 'ignoring: ' + config . options . monitor . map ( function ( rule ) {
143146 return rule . slice ( 0 , 1 ) === '!' ? rule . slice ( 1 ) : false ;
144- } ) . filter ( none ) . join ( ' ' ) ) ;
147+ } ) . filter ( Boolean ) . join ( ' ' ) ) ;
145148
146149 utils . log . info ( 'watching: ' + config . options . monitor . map ( function ( rule ) {
147150 return rule . slice ( 0 , 1 ) !== '!' ? rule : false ;
148- } ) . filter ( none ) . join ( ' ' ) ) ;
151+ } ) . filter ( Boolean ) . join ( ' ' ) ) ;
149152
150153 utils . log . detail ( 'watching extensions: ' + config . options . execOptions . ext ) ;
151154
152-
153155 if ( config . options . dump ) {
154156 utils . log . _log ( 'log' , '--------------' ) ;
155157 utils . log . _log ( 'log' , 'node: ' + process . version ) ;
@@ -164,33 +166,35 @@ function nodemon(settings) {
164166 process . exit ( ) ;
165167 }
166168
167- } else {
168- config . run = true ;
169+ return ;
170+ }
169171
170- if ( config . options . stdout === false ) {
171- nodemon . on ( 'start' , function ( ) {
172- nodemon . stdout = bus . stdout ;
173- nodemon . stderr = bus . stderr ;
172+ config . run = true ;
174173
175- bus . emit ( 'readable' ) ;
176- } ) ;
177- }
174+ if ( config . options . stdout === false ) {
175+ nodemon . on ( 'start' , function ( ) {
176+ nodemon . stdout = bus . stdout ;
177+ nodemon . stderr = bus . stderr ;
178178
179- if ( config . options . events && Object . keys ( config . options . events ) . length ) {
180- Object . keys ( config . options . events ) . forEach ( function ( key ) {
181- utils . log . detail ( 'bind ' + key + ' -> `' +
182- config . options . events [ key ] + '`' ) ;
183- nodemon . on ( key , function ( ) {
184- if ( config . options && config . options . events ) {
185- spawn ( config . options . events [ key ] , config ,
186- [ ] . slice . apply ( arguments ) ) ;
187- }
188- } ) ;
189- } ) ;
190- }
179+ bus . emit ( 'readable' ) ;
180+ } ) ;
181+ }
191182
192- monitor . run ( config . options ) ;
183+ if ( config . options . events && Object . keys ( config . options . events ) . length ) {
184+ Object . keys ( config . options . events ) . forEach ( function ( key ) {
185+ utils . log . detail ( 'bind ' + key + ' -> `' +
186+ config . options . events [ key ] + '`' ) ;
187+ nodemon . on ( key , function ( ) {
188+ if ( config . options && config . options . events ) {
189+ spawn ( config . options . events [ key ] , config ,
190+ [ ] . slice . apply ( arguments ) ) ;
191+ }
192+ } ) ;
193+ } ) ;
193194 }
195+
196+ monitor . run ( config . options ) ;
197+
194198 } ) ;
195199
196200 return nodemon ;
0 commit comments