@@ -34,10 +34,8 @@ markBootstrapComplete();
3434
3535const kKillSignal = convertToValidSignal ( getOptionValue ( '--watch-kill-signal' ) ) ;
3636const kShouldFilterModules = getOptionValue ( '--watch-path' ) . length === 0 ;
37- const kEnvFiles = [
38- ...getOptionValue ( '--env-file' ) ,
39- ...getOptionValue ( '--env-file-if-exists' ) ,
40- ] ;
37+ const kEnvFiles = getOptionValue ( '--env-file' ) ;
38+ const kOptionalEnvFiles = getOptionValue ( '--env-file-if-exists' ) ;
4139const kWatchedPaths = ArrayPrototypeMap ( getOptionValue ( '--watch-path' ) , ( path ) => resolve ( path ) ) ;
4240const kPreserveOutput = getOptionValue ( '--watch-preserve-output' ) ;
4341const kCommand = ArrayPrototypeSlice ( process . argv , 1 ) ;
@@ -105,6 +103,10 @@ function start() {
105103 if ( kEnvFiles . length > 0 ) {
106104 ArrayPrototypeForEach ( kEnvFiles , ( file ) => watcher . filterFile ( resolve ( file ) ) ) ;
107105 }
106+ if ( kOptionalEnvFiles . length > 0 ) {
107+ ArrayPrototypeForEach ( kOptionalEnvFiles ,
108+ ( file ) => watcher . filterFile ( resolve ( file ) , undefined , { allowMissing : true } ) ) ;
109+ }
108110 child . once ( 'exit' , ( code ) => {
109111 exited = true ;
110112 const waitingForChanges = 'Waiting for file changes before restarting...' ;
@@ -160,6 +162,7 @@ async function stop(child) {
160162}
161163
162164let restarting = false ;
165+
163166async function restart ( child ) {
164167 if ( restarting ) return ;
165168 restarting = true ;
@@ -198,5 +201,6 @@ function signalHandler(signal) {
198201 process . exit ( exitCode ?? kNoFailure ) ;
199202 } ;
200203}
204+
201205process . on ( 'SIGTERM' , signalHandler ( 'SIGTERM' ) ) ;
202206process . on ( 'SIGINT' , signalHandler ( 'SIGINT' ) ) ;
0 commit comments