Skip to content

Commit

Permalink
Improve config logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 23, 2022
1 parent 85382c6 commit eb9e6b2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/config/normalize/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { cleanObject } from '../../utils/clean.js'
import { mapValues } from '../../utils/map.js'

import { runNormalizer } from './check.js'
import { runDagAsync } from './dag/run.js'
import { getEntries } from './prop_path/get.js'
import { set } from './prop_path/set.js'
import { CONFIG_PROPS } from './properties.js'

// Normalize configuration shape and do custom validation.
Expand All @@ -28,7 +30,8 @@ export const normalizeConfig = async function (config, command, configInfos) {
)
const configProps = await runDagAsync(configPropsFuncs)
const configA = mergeConfigProps(configProps)
return configA
const configB = cleanObject(configA)
return configB
}

const normalizePropDeep = async function (
Expand Down Expand Up @@ -109,6 +112,6 @@ const mergeConfigProps = function (configProps) {
return Object.entries(configProps).reduce(setConfigProp, {})
}

const setConfigProp = function (config, [name, value]) {
return value === undefined ? config : { ...config, [name]: value[0] }
const setConfigProp = function (config, [query, value]) {
return set(config, query, value[0])
}

0 comments on commit eb9e6b2

Please sign in to comment.