Skip to content

Commit

Permalink
Allow normalizer to be async
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 16, 2022
1 parent afd25c3 commit be6fbd9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/config/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ const normalizePropValue = async function (
const args = [name, { configInfos, config: configPromises, command }]

const valueA = await addDefaultValue(value, defaultValue, args)

return valueA === undefined || normalize === undefined
? valueA
: runNormalizer(normalize, valueA, ...args)
return await runPropNormalizer(valueA, normalize, args)
}

// All config properties can be specified in `spyd.yml` (unlike CLI flags), for
Expand Down Expand Up @@ -93,6 +90,12 @@ const addDefaultValue = async function (value, defaultValue, args) {
return await defaultValue(...args)
}

const runPropNormalizer = async function (value, normalize, args) {
return value === undefined || normalize === undefined
? value
: await runNormalizer(normalize, value, ...args)
}

const mergeConfigProps = function (configProps) {
return Object.entries(configProps).reduce(setConfigProp, {})
}
Expand Down

0 comments on commit be6fbd9

Please sign in to comment.