| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a433759 commit 30e3818
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ const { | |||
| 18 | 18 | triggerUncaughtException, | |
| 19 | 19 | exitCodes: { kNoFailure }, | |
| 20 | 20 | } = internalBinding('errors'); | |
| 21 | - const { getOptionValue, getOptionsAsFlagsFromBinding } = require('internal/options'); | ||
| 21 | + const { getOptionValue } = require('internal/options'); | ||
| 22 | 22 | const { FilesWatcher } = require('internal/watch_mode/files_watcher'); | |
| 23 | 23 | const { green, blue, red, white, clear } = require('internal/util/colors'); | |
| 24 | 24 | const { convertToValidSignal } = require('internal/util'); | |
@@ -44,14 +44,13 @@ const kCommand = ArrayPrototypeSlice(process.argv, 1); | |||
| 44 | 44 | const kCommandStr = inspect(ArrayPrototypeJoin(kCommand, ' ')); | |
| 45 | 45 | ||
| 46 | 46 | const argsWithoutWatchOptions = []; | |
| 47 | - const argsFromBinding = getOptionsAsFlagsFromBinding(); | ||
| 48 | - for (let i = 0; i < argsFromBinding.length; i++) { | ||
| 49 | - const arg = argsFromBinding[i]; | ||
| 47 | + for (let i = 0; i < process.execArgv.length; i++) { | ||
| 48 | + const arg = process.execArgv[i]; | ||
| 50 | 49 | if (StringPrototypeStartsWith(arg, '--watch=')) { | |
| 51 | 50 | continue; | |
| 52 | 51 | } | |
| 53 | 52 | if (arg === '--watch') { | |
| 54 | - const nextArg = argsFromBinding[i + 1]; | ||
| 53 | + const nextArg = process.execArgv[i + 1]; | ||
| 55 | 54 | if (nextArg && nextArg[0] !== '-') { | |
| 56 | 55 | // If `--watch` doesn't include `=` and the next | |
| 57 | 56 | // argument is not a flag then it is interpreted as | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -893,4 +893,33 @@ process.on('message', (message) => { | |||
| 893 | 893 | await done(); | |
| 894 | 894 | } | |
| 895 | 895 | }); | |
| 896 | + | ||
| 897 | + it('should respect the order for --env-file and --env-file-if-exists', async () => { | ||
| 898 | + const envKey = `TEST_ENV_${Date.now()}`; | ||
| 899 | + const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`); | ||
| 900 | + | ||
| 901 | + const envFile = createTmpFile(`${envKey}=base`, '.env'); | ||
| 902 | + const envFileIfExists = createTmpFile(`${envKey}=override`, '.env'); | ||
| 903 | + | ||
| 904 | + const { done, restart } = runInBackground({ | ||
| 905 | + args: [ | ||
| 906 | + '--watch', | ||
| 907 | + `--env-file=${envFile}`, | ||
| 908 | + `--env-file-if-exists=${envFileIfExists}`, | ||
| 909 | + jsFile, | ||
| 910 | + ], | ||
| 911 | + }); | ||
| 912 | + | ||
| 913 | + try { | ||
| 914 | + const { stdout, stderr } = await restart(); | ||
| 915 | + | ||
| 916 | + assert.strictEqual(stderr, ''); | ||
| 917 | + assert.deepStrictEqual(stdout, [ | ||
| 918 | + 'ENV: override', | ||
| 919 | + `Completed running ${inspect(jsFile)}. Waiting for file changes before restarting...`, | ||
| 920 | + ]); | ||
| 921 | + } finally { | ||
| 922 | + await done(); | ||
| 923 | + } | ||
| 924 | + }); | ||
| 896 | 925 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments