| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 727560a commit d64795b
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,7 +34,10 @@ markBootstrapComplete(); | |||
| 34 | 34 | ||
| 35 | 35 | const kKillSignal = convertToValidSignal(getOptionValue('--watch-kill-signal')); | |
| 36 | 36 | const kShouldFilterModules = getOptionValue('--watch-path').length === 0; | |
| 37 | - const kEnvFile = getOptionValue('--env-file') || getOptionValue('--env-file-if-exists'); | ||
| 37 | + const kEnvFiles = [ | ||
| 38 | + ...getOptionValue('--env-file'), | ||
| 39 | + ...getOptionValue('--env-file-if-exists'), | ||
| 40 | + ]; | ||
| 38 | 41 | const kWatchedPaths = ArrayPrototypeMap(getOptionValue('--watch-path'), (path) => resolve(path)); | |
| 39 | 42 | const kPreserveOutput = getOptionValue('--watch-preserve-output'); | |
| 40 | 43 | const kCommand = ArrayPrototypeSlice(process.argv, 1); | |
@@ -100,8 +103,8 @@ function start() { | |||
| 100 | 103 | }, | |
| 101 | 104 | }); | |
| 102 | 105 | watcher.watchChildProcessModules(child); | |
| 103 | - if (kEnvFile) { | ||
| 104 | - watcher.filterFile(resolve(kEnvFile)); | ||
| 106 | + if (kEnvFiles.length > 0) { | ||
| 107 | + ArrayPrototypeForEach(kEnvFiles, (file) => watcher.filterFile(resolve(file))); | ||
| 105 | 108 | } | |
| 106 | 109 | child.once('exit', (code) => { | |
| 107 | 110 | exited = true; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -185,8 +185,8 @@ class EnvironmentOptions : public Options { | |||
| 185 | 185 | #endif // HAVE_INSPECTOR | |
| 186 | 186 | std::string redirect_warnings; | |
| 187 | 187 | std::string diagnostic_dir; | |
| 188 | - std::string env_file; | ||
| 189 | - std::string optional_env_file; | ||
| 188 | + std::vector<std::string> env_file; | ||
| 189 | + std::vector<std::string> optional_env_file; | ||
| 190 | 190 | bool has_env_file_string = false; | |
| 191 | 191 | bool test_runner = false; | |
| 192 | 192 | uint64_t test_runner_concurrency = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,6 +39,17 @@ describe('.env supports edge cases', () => { | |||
| 39 | 39 | }))); | |
| 40 | 40 | }); | |
| 41 | 41 | ||
| 42 | + it('should not support comma-separated env files', async () => { | ||
| 43 | + const code = 'assert.strictEqual(1, 1)'; | ||
| 44 | + const child = await common.spawnPromisified( | ||
| 45 | + process.execPath, | ||
| 46 | + [`--env-file=${validEnvFilePath},${nodeOptionsEnvFilePath}`, '--eval', code], | ||
| 47 | + { cwd: __dirname }, | ||
| 48 | + ); | ||
| 49 | + assert.notStrictEqual(child.stderr, ''); | ||
| 50 | + assert.strictEqual(child.code, 9); | ||
| 51 | + }); | ||
| 52 | + | ||
| 42 | 53 | it('supports absolute paths', async () => { | |
| 43 | 54 | const code = ` | |
| 44 | 55 | assert.strictEqual(process.env.BASIC, 'basic'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -860,4 +860,28 @@ process.on('message', (message) => { | |||
| 860 | 860 | `Completed running ${inspect(file)}. Waiting for file changes before restarting...`, | |
| 861 | 861 | ]); | |
| 862 | 862 | }); | |
| 863 | + | ||
| 864 | + it('should support multiple --env-file flags', async () => { | ||
| 865 | + const envKey = `TEST_ENV_A_${Date.now()}`; | ||
| 866 | + const envKey2 = `TEST_ENV_B_${Date.now()}`; | ||
| 867 | + const jsFile = createTmpFile(`console.log('ENV_A: ' + process.env.${envKey} + '\\n' + 'ENV_B: ' + process.env.${envKey2});`); | ||
| 868 | + const envFileA = createTmpFile(`${envKey}=123`, '.env'); | ||
| 869 | + const envFileB = createTmpFile(`${envKey2}=456`, '.env'); | ||
| 870 | + const { done, restart } = runInBackground({ | ||
| 871 | + args: ['--watch', `--env-file=${envFileA}`, `--env-file=${envFileB}`, jsFile] | ||
| 872 | + }); | ||
| 873 | + | ||
| 874 | + try { | ||
| 875 | + const { stderr, stdout } = await restart(); | ||
| 876 | + | ||
| 877 | + assert.strictEqual(stderr, ''); | ||
| 878 | + assert.deepStrictEqual(stdout, [ | ||
| 879 | + 'ENV_A: 123', | ||
| 880 | + 'ENV_B: 456', | ||
| 881 | + `Completed running ${inspect(jsFile)}. Waiting for file changes before restarting...`, | ||
| 882 | + ]); | ||
| 883 | + } finally { | ||
| 884 | + await done(); | ||
| 885 | + } | ||
| 886 | + }); | ||
| 863 | 887 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments