Skip to content

Commit

Permalink
Add amongCommands()
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 23, 2022
1 parent 73ac180 commit 55d21ca
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/config/normalize/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ import {
// eslint-disable-next-line import/max-dependencies
import { normalizeConfigPath, normalizeConfigGlob } from './path.js'

// Used a `condition()` to filter a configuration property for specific commands
const amongCommands = function (commands) {
return boundAmongCommands.bind(undefined, new Set(commands))
}

const boundAmongCommands = function (
commands,
value,
{ context: { command } },
) {
return commands.has(command)
}

const config = {
async default() {
return await getDefaultConfig()
Expand Down Expand Up @@ -136,9 +149,7 @@ const quiet = {

const reporter = [
{
condition(value, { context: { command } }) {
return command === 'remove'
},
condition: amongCommands(['remove']),
async transform(value, { get }) {
return (await get('force')) ? [] : value
},
Expand Down

0 comments on commit 55d21ca

Please sign in to comment.