Skip to content

Commit

Permalink
Extract new (converted) flag assembly logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen committed Jan 8, 2025
1 parent 555b162 commit bd8d98d
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 @@ -84,20 +84,15 @@ export const handler = async ({
return []
} else {
// and forward on the other flags
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`
const flagValue = others[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) => [flag, val])
} else {
return [
flagName.length > 1 ? `--${flagName}` : `-${flagName}`,
flagValue,
]
return [flag, flagValue]
}
}
})
Expand Down

0 comments on commit bd8d98d

Please sign in to comment.