config-loader: use multiple config roots
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import { pathExists } from 'fs-extra';
|
||||
|
||||
type ResolveOptions = {
|
||||
// Root path for search for app-config.yaml
|
||||
rootPath: string;
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
rootPaths: string[];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -29,7 +30,14 @@ export async function resolveStaticConfig(
|
||||
): Promise<string[]> {
|
||||
// TODO: We'll want this to be a bit more elaborate, probably adding configs for
|
||||
// specific env, and maybe local config for plugins.
|
||||
const configPath = resolvePath(options.rootPath, 'app-config.yaml');
|
||||
const resolvedPaths = [];
|
||||
|
||||
return [configPath];
|
||||
for (const rootPath of options.rootPaths) {
|
||||
const path = resolvePath(rootPath, 'app-config.yaml');
|
||||
if (await pathExists(path)) {
|
||||
resolvedPaths.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
return resolvedPaths;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import {
|
||||
} from './lib';
|
||||
|
||||
export type LoadConfigOptions = {
|
||||
// Root path for search for app-config.yaml
|
||||
rootPath: string;
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
rootPaths: string[];
|
||||
|
||||
// Whether to read secrets or omit them, defaults to false.
|
||||
shouldReadSecrets?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user