@@ -34,10 +34,8 @@ markBootstrapComplete();
|
34 | 34 | |
35 | 35 | const kKillSignal = convertToValidSignal(getOptionValue('--watch-kill-signal')); |
36 | 36 | const 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'); |
41 | 39 | const kWatchedPaths = ArrayPrototypeMap(getOptionValue('--watch-path'), (path) => resolve(path)); |
42 | 40 | const kPreserveOutput = getOptionValue('--watch-preserve-output'); |
43 | 41 | const kCommand = ArrayPrototypeSlice(process.argv, 1); |
@@ -105,6 +103,10 @@ function start() {
|
105 | 103 | if (kEnvFiles.length > 0) { |
106 | 104 | ArrayPrototypeForEach(kEnvFiles, (file) => watcher.filterFile(resolve(file))); |
107 | 105 | } |
| 106 | +if (kOptionalEnvFiles.length > 0) { |
| 107 | +ArrayPrototypeForEach(kOptionalEnvFiles, |
| 108 | +(file) => watcher.filterFile(resolve(file), undefined, { allowMissing: true })); |
| 109 | +} |
108 | 110 | child.once('exit', (code) => { |
109 | 111 | exited = true; |
110 | 112 | const waitingForChanges = 'Waiting for file changes before restarting...'; |
@@ -160,6 +162,7 @@ async function stop(child) {
|
160 | 162 | } |
161 | 163 | |
162 | 164 | let restarting = false; |
| 165 | + |
163 | 166 | async function restart(child) { |
164 | 167 | if (restarting) return; |
165 | 168 | restarting = true; |
@@ -198,5 +201,6 @@ function signalHandler(signal) {
|
198 | 201 | process.exit(exitCode ?? kNoFailure); |
199 | 202 | }; |
200 | 203 | } |
| 204 | + |
201 | 205 | process.on('SIGTERM', signalHandler('SIGTERM')); |
202 | 206 | process.on('SIGINT', signalHandler('SIGINT')); |