Skip to content

Commit

Permalink
Move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 13, 2022
1 parent c7536cd commit 5cd24d5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/config/normalize/lib/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const applyDefinition = async function (
condition,
default: defaultValue,
compute,
path = false,
glob = false,
required = false,
path,
glob,
required,
validate,
transform,
rename,
Expand Down
29 changes: 29 additions & 0 deletions src/config/normalize/lib/definition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export const normalizeDefinition = function ({
name,
pick,
condition,
default: defaultValue,
compute,
path = false,
glob = false,
required = false,
example,
validate,
transform,
rename,
}) {
return {
name,
pick,
condition,
default: defaultValue,
compute,
path,
glob,
required,
example,
validate,
transform,
rename,
}
}
5 changes: 4 additions & 1 deletion src/config/normalize/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import pReduce from 'p-reduce'
import { cleanObject } from '../../../utils/clean.js'

import { applyDefinition } from './apply.js'
import { normalizeDefinition } from './definition.js'
import { getOpts } from './opts.js'
import { DEFAULT_PREFIX } from './prefix.js'
import { list } from './prop_path/get.js'
Expand All @@ -24,9 +25,11 @@ export const normalizeConfigProps = async function (
definitions,
{ context = {}, loose = false, cwd, prefix = DEFAULT_PREFIX } = {},
) {
const definitionsA = definitions.map(normalizeDefinition)

try {
const configB = await pReduce(
definitions,
definitionsA,
(configA, definition) =>
applyDefinitionDeep({
config: configA,
Expand Down

0 comments on commit 5cd24d5

Please sign in to comment.