mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
watch: fix interaction with multiple env files
PR-URL: https://github.com/nodejs/node/pull/60605 Fixes: https://github.com/nodejs/node/issues/60599 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
@@ -860,4 +860,28 @@ process.on('message', (message) => {
|
||||
`Completed running ${inspect(file)}. Waiting for file changes before restarting...`,
|
||||
]);
|
||||
});
|
||||
|
||||
it('should support multiple --env-file flags', async () => {
|
||||
const envKey = `TEST_ENV_A_${Date.now()}`;
|
||||
const envKey2 = `TEST_ENV_B_${Date.now()}`;
|
||||
const jsFile = createTmpFile(`console.log('ENV_A: ' + process.env.${envKey} + '\\n' + 'ENV_B: ' + process.env.${envKey2});`);
|
||||
const envFileA = createTmpFile(`${envKey}=123`, '.env');
|
||||
const envFileB = createTmpFile(`${envKey2}=456`, '.env');
|
||||
const { done, restart } = runInBackground({
|
||||
args: ['--watch', `--env-file=${envFileA}`, `--env-file=${envFileB}`, jsFile]
|
||||
});
|
||||
|
||||
try {
|
||||
const { stderr, stdout } = await restart();
|
||||
|
||||
assert.strictEqual(stderr, '');
|
||||
assert.deepStrictEqual(stdout, [
|
||||
'ENV_A: 123',
|
||||
'ENV_B: 456',
|
||||
`Completed running ${inspect(jsFile)}. Waiting for file changes before restarting...`,
|
||||
]);
|
||||
} finally {
|
||||
await done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user