Skip to content

Commit

Permalink
Add multiple functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 20, 2022
1 parent 948ce98 commit 12385ec
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/config/plugin/lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const normalizeList = async function ({
list,
default: defaultValue,
name,
multiple,
builtins,
pluginProp,
modulePrefix,
Expand All @@ -21,7 +22,7 @@ export const normalizeList = async function ({
const isArray = Array.isArray(pluginConfigs)
const pluginConfigsA = await safeNormalizeConfig(
pluginConfigs,
getListDefinitions(list),
getListDefinitions(list, multiple),
{
context,
cwd,
Expand All @@ -43,9 +44,19 @@ export const normalizeList = async function ({
)
}

const getListDefinitions = function (list) {
const getListDefinitions = function (list, multiple) {
return [
{ name: '', transform: normalizeOptionalArray },
{
name: '',
validate: validateMultiple.bind(undefined, multiple),
transform: normalizeOptionalArray,
},
{ ...list, name: '' },
]
}

const validateMultiple = function (multiple, value) {
if (!multiple && Array.isArray(value)) {
throw new Error('must not be an array.')
}
}

0 comments on commit 12385ec

Please sign in to comment.