Skip to content

Commit

Permalink
Extract new (coverted) flag assembly logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen committed Jan 7, 2025
1 parent 13ef795 commit 09012d9
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/cli/src/commands/testHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,14 @@ export const handler = async ({
} else {
// and forward on the other flags
const flagValue = others[flagName]
const newFlag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`

if (Array.isArray(flagValue)) {
// jest does not collapse flags e.g. --coverageReporters=html --coverageReporters=text
// so we pass it on. Yargs collapses these flags into an array of values
return flagValue.flatMap((val) => [
flagName.length > 1 ? `--${flagName}` : `-${flagName}`,
val,
])
return flagValue.flatMap((val) => [newFlag, val])
} else {
return [
flagName.length > 1 ? `--${flagName}` : `-${flagName}`,
flagValue,
]
return [newFlag, flagValue]
}
}
})
Expand Down

0 comments on commit 09012d9

Please sign in to comment.