Skip to content

Commit 0b4b442

Browse files
authored
Merge pull request #63 from DouglasNeuroInformatics/dev
allow specifying multiple env files @joshunrau
2 parents b6bc717 + 9fedd2f commit 0b4b442

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/cli/libnest.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ program.requiredOption('-c, --config-file <path>', 'path to the config file', (f
3636
return parseResult(resolveAbsoluteImportPath(filename, process.cwd()));
3737
});
3838

39-
program.option('-e, --env-file <path>', 'path to an env file to source', (filename) => {
40-
return parseResult(resolveAbsolutePath(filename, process.cwd()));
39+
program.option('-e, --env-file <paths...>', 'path to env file(s) to source', (filename, previous) => {
40+
return (previous ?? []).concat(parseResult(resolveAbsolutePath(filename, process.cwd())));
4141
});
4242

4343
program.addOption(
@@ -52,10 +52,9 @@ program.command('dev', 'run application in development mode', {
5252
});
5353

5454
program.hook('preSubcommand', (command) => {
55-
const envFile = command.getOptionValue('envFile');
56-
if (envFile) {
55+
command.getOptionValue('envFile')?.forEach((/** @type {string} */ envFile) => {
5756
process.loadEnvFile(envFile);
58-
}
57+
});
5958
process.env.LIBNEST_CONFIG_FILEPATH = command.getOptionValue('configFile');
6059
process.env.LIBNEST_JAVASCRIPT_RUNTIME = command.getOptionValue('runtime');
6160
});

src/utils/env.utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export function parseEnv<TSchema extends BaseEnvSchema = BaseEnvSchema>(schema:
1414
);
1515
if (envConfigResult.isErr()) {
1616
throw new RuntimeException('Failed to parse environment config', {
17-
cause: envConfigResult.error
17+
details: {
18+
issues: envConfigResult.error.details.issues
19+
}
1820
});
1921
}
2022
// eslint-disable-next-line @typescript-eslint/no-unsafe-return

0 commit comments

Comments
 (0)