config: flip priority order of ConfigReader.fromConfigs
This commit is contained in:
@@ -57,16 +57,16 @@ describe('resolveStaticConfig', () => {
|
||||
const resolved = await resolveStaticConfig({
|
||||
env: 'development',
|
||||
rootPaths: [
|
||||
'/repo',
|
||||
'/other-repo',
|
||||
'/repo/packages/a',
|
||||
'/repo/packages/b',
|
||||
'/other-repo',
|
||||
'/repo',
|
||||
],
|
||||
});
|
||||
|
||||
expect(resolved).toEqual([
|
||||
'/repo/packages/a/app-config.yaml',
|
||||
'/repo/app-config.yaml',
|
||||
'/repo/packages/a/app-config.yaml',
|
||||
]);
|
||||
expect(pathExists).toHaveBeenCalledTimes(16);
|
||||
});
|
||||
@@ -85,15 +85,15 @@ describe('resolveStaticConfig', () => {
|
||||
);
|
||||
const resolved = await resolveStaticConfig({
|
||||
env: 'development',
|
||||
rootPaths: ['/repo/packages/a', '/repo'],
|
||||
rootPaths: ['/repo', '/repo/packages/a'],
|
||||
});
|
||||
|
||||
expect(resolved).toEqual([
|
||||
'/repo/packages/a/app-config.development.yaml',
|
||||
'/repo/packages/a/app-config.local.yaml',
|
||||
'/repo/app-config.development.local.yaml',
|
||||
'/repo/app-config.local.yaml',
|
||||
'/repo/app-config.yaml',
|
||||
'/repo/app-config.local.yaml',
|
||||
'/repo/app-config.development.local.yaml',
|
||||
'/repo/packages/a/app-config.local.yaml',
|
||||
'/repo/packages/a/app-config.development.yaml',
|
||||
]);
|
||||
expect(pathExists).toHaveBeenCalledTimes(8);
|
||||
});
|
||||
@@ -106,10 +106,10 @@ describe('resolveStaticConfig', () => {
|
||||
});
|
||||
|
||||
expect(resolved).toEqual([
|
||||
'/repo/app-config.production.local.yaml',
|
||||
'/repo/app-config.production.yaml',
|
||||
'/repo/app-config.local.yaml',
|
||||
'/repo/app-config.yaml',
|
||||
'/repo/app-config.local.yaml',
|
||||
'/repo/app-config.production.yaml',
|
||||
'/repo/app-config.production.local.yaml',
|
||||
]);
|
||||
expect(pathExists).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { resolve as resolvePath } from 'path';
|
||||
import { pathExists } from 'fs-extra';
|
||||
|
||||
type ResolveOptions = {
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
// Root paths to search for config files. Config from earlier paths has lower priority.
|
||||
rootPaths: string[];
|
||||
// The environment that we're loading config for, e.g. 'development', 'production'.
|
||||
env: string;
|
||||
@@ -38,10 +38,10 @@ export async function resolveStaticConfig(
|
||||
options: ResolveOptions,
|
||||
): Promise<string[]> {
|
||||
const filePaths = [
|
||||
`app-config.${options.env}.local.yaml`,
|
||||
`app-config.${options.env}.yaml`,
|
||||
`app-config.local.yaml`,
|
||||
`app-config.yaml`,
|
||||
`app-config.local.yaml`,
|
||||
`app-config.${options.env}.yaml`,
|
||||
`app-config.${options.env}.local.yaml`,
|
||||
];
|
||||
|
||||
const resolvedPaths = [];
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from './lib';
|
||||
|
||||
export type LoadConfigOptions = {
|
||||
// Root paths to search for config files. Config from earlier paths has higher priority.
|
||||
// Root paths to search for config files. Config from earlier paths has lower priority.
|
||||
rootPaths: string[];
|
||||
|
||||
// The environment that we're loading config for, e.g. 'development', 'production'.
|
||||
@@ -66,8 +66,6 @@ export async function loadConfig(
|
||||
): Promise<AppConfig[]> {
|
||||
const configs = [];
|
||||
|
||||
configs.push(...readEnv(process.env));
|
||||
|
||||
const configPaths = await resolveStaticConfig(options);
|
||||
|
||||
try {
|
||||
@@ -89,5 +87,7 @@ export async function loadConfig(
|
||||
);
|
||||
}
|
||||
|
||||
configs.push(...readEnv(process.env));
|
||||
|
||||
return configs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user