config-loader: pass in env as an option

This commit is contained in:
Patrik Oldsberg
2020-08-07 10:52:50 +02:00
parent 74edab290a
commit a37aa1d994
8 changed files with 13 additions and 4 deletions
+4 -4
View File
@@ -20,6 +20,8 @@ import { pathExists } from 'fs-extra';
type ResolveOptions = {
// Root paths to search for config files. Config from earlier paths has higher priority.
rootPaths: string[];
// The environment that we're loading config for, e.g. 'development', 'production'.
env: string;
};
/**
@@ -35,11 +37,9 @@ type ResolveOptions = {
export async function resolveStaticConfig(
options: ResolveOptions,
): Promise<string[]> {
const env = process.env.NODE_ENV ?? 'development';
const filePaths = [
`app-config.${env}.local.yaml`,
`app-config.${env}.yaml`,
`app-config.${options.env}.local.yaml`,
`app-config.${options.env}.yaml`,
`app-config.local.yaml`,
`app-config.yaml`,
];
+3
View File
@@ -28,6 +28,9 @@ export type LoadConfigOptions = {
// Root paths to search for config files. Config from earlier paths has higher priority.
rootPaths: string[];
// The environment that we're loading config for, e.g. 'development', 'production'.
env: string;
// Whether to read secrets or omit them, defaults to false.
shouldReadSecrets?: boolean;
};