refactor: resolve configs immediately

This commit is contained in:
Rhys Arkins 2018-06-21 08:43:19 +02:00
parent 12519bbf8f
commit 2decb37a1d

View file

@ -36,17 +36,14 @@ async function parseConfigs(env, argv) {
logger.debug('Parsing configs');
// Get configs
const defaultConfig = defaultsParser.getConfig();
const fileConfig = fileParser.getConfig(env);
const cliConfig = cliParser.getConfig(argv);
const envConfig = envParser.getConfig(env);
const defaultConfig = await resolveConfigPresets(defaultsParser.getConfig());
const fileConfig = await resolveConfigPresets(fileParser.getConfig(env));
const cliConfig = await resolveConfigPresets(cliParser.getConfig(argv));
const envConfig = await resolveConfigPresets(envParser.getConfig(env));
let config = mergeChildConfig(
await resolveConfigPresets(defaultConfig),
await resolveConfigPresets(fileConfig)
);
config = mergeChildConfig(config, await resolveConfigPresets(envConfig));
config = mergeChildConfig(config, await resolveConfigPresets(cliConfig));
let config = mergeChildConfig(defaultConfig, fileConfig);
config = mergeChildConfig(config, envConfig);
config = mergeChildConfig(config, cliConfig);
// Set log level
logger.levels('stdout', config.logLevel);