Skip to content

Commit

Permalink
Use condition()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 23, 2022
1 parent 823e045 commit b6e753a
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/config/normalize/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,22 @@ const quiet = {
},
}

const reporter = {
default: ['debug'],
transform(value) {
return normalizeOptionalArray(value)
},
}

// `reporter` configuration property specific logic for the `remove` command
const reporterRemove = {
...reporter,
async transform(value, { name, get }) {
const forceValue = await get('force')
return forceValue ? [] : reporter.transform(value, { name })
},
}
const reporter = [
{
condition(value, { context: { command } }) {
return command === 'remove'
},
async transform(value, { get }) {
return (await get('force')) ? [] : value
},
},
{
default: ['debug'],
transform(value) {
return normalizeOptionalArray(value)
},
},
]

const reporterAny = {
transform(value, { name }) {
Expand Down Expand Up @@ -324,7 +325,7 @@ export const COMMANDS_PROPS = {
force,
limit,
output,
reporter: reporterRemove,
reporter,
'reporter[*]': reporterAny,
reporterConfig,
select,
Expand Down

0 comments on commit b6e753a

Please sign in to comment.