|
9 | 9 | aliases, |
10 | 10 | expectedTypeForFlag, |
11 | 11 | isMochaFlag, |
| 12 | + stripLeadingDashes, |
12 | 13 | types, |
13 | 14 | } from "./run-option-metadata.cjs"; |
14 | 15 | import { isNodeFlag } from "./node-flags.cjs"; |
@@ -161,7 +162,7 @@ const mergeConfigObjects = (defaultValues, configObjects) => { |
161 | 162 |
|
162 | 163 | const preprocessArgs = (allArgs) => { |
163 | 164 | return allArgs.map((arg) => { |
164 | | - const noPrefix = arg.replace(/^--?/, ""); |
| 165 | + const noPrefix = stripLeadingDashes(arg); |
165 | 166 | const [name, ...rest] = noPrefix.split("="); |
166 | 167 | const canonical = canonicalOptionName(name.replace(/^no-/, "")); |
167 | 168 | const negated = name.startsWith("no-"); |
@@ -194,7 +195,7 @@ const validateArgsBeforeParse = (allArgs) => { |
194 | 195 | return; |
195 | 196 | } |
196 | 197 |
|
197 | | - const name = canonicalOptionName(arg.replace(/^--?/, "")); |
| 198 | + const name = canonicalOptionName(stripLeadingDashes(arg)); |
198 | 199 | const next = allArgs[index + 1]; |
199 | 200 |
|
200 | 201 | if (requiresValue(name) && (next === undefined || next.startsWith("-"))) { |
@@ -249,7 +250,7 @@ const createErrorForNumericPositionalArg = ( |
249 | 250 | // 2. parseArgs() could not assign the numericArg to that flag because the |
250 | 251 | // option has an incompatible datatype. |
251 | 252 | const flag = allArgs.find((arg, index) => { |
252 | | - const normalizedArg = arg.replace(/^--?/, ""); |
| 253 | + const normalizedArg = stripLeadingDashes(arg); |
253 | 254 | return ( |
254 | 255 | isMochaFlag(arg) && |
255 | 256 | allArgs[index + 1] === String(numericArg) && |
@@ -283,7 +284,7 @@ export const parseMochaArgs = ( |
283 | 284 | const pair = arg.split("="); |
284 | 285 | let flag = pair[0]; |
285 | 286 | if (isNodeFlag(flag, false)) { |
286 | | - flag = flag.replace(/^--?/, ""); |
| 287 | + flag = stripLeadingDashes(flag); |
287 | 288 | return acc.concat([[flag, arg.includes("=") ? pair[1] : true]]); |
288 | 289 | } |
289 | 290 | return acc; |
|
0 commit comments