(extraArgs?: readonly string[])
| 3 | } |
| 4 | |
| 5 | export function parseResultBundlePathArgs(extraArgs?: readonly string[]): { |
| 6 | remainingArgs: string[]; |
| 7 | resultBundlePath?: string; |
| 8 | } { |
| 9 | if (!extraArgs) { |
| 10 | return { remainingArgs: [] }; |
| 11 | } |
| 12 | |
| 13 | const remainingArgs: string[] = []; |
| 14 | let resultBundlePath: string | undefined; |
| 15 | |
| 16 | for (let index = 0; index < extraArgs.length; index += 1) { |
| 17 | const argument = extraArgs[index]; |
| 18 | if (argument === '-resultBundlePath') { |
| 19 | const value = extraArgs[index + 1]; |
| 20 | if (isResultBundlePathValue(value)) { |
| 21 | resultBundlePath = value; |
| 22 | index += 1; |
| 23 | } |
| 24 | continue; |
| 25 | } |
| 26 | |
| 27 | if (argument?.startsWith('-resultBundlePath=')) { |
| 28 | const value = argument.slice('-resultBundlePath='.length); |
| 29 | if (isResultBundlePathValue(value)) { |
| 30 | resultBundlePath = value; |
| 31 | } |
| 32 | continue; |
| 33 | } |
| 34 | |
| 35 | if (argument !== undefined) { |
| 36 | remainingArgs.push(argument); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | return { |
| 41 | remainingArgs, |
| 42 | ...(resultBundlePath ? { resultBundlePath } : {}), |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | export function findResultBundlePathArg(extraArgs?: readonly string[]): string | undefined { |
| 47 | return parseResultBundlePathArgs(extraArgs).resultBundlePath; |
no test coverage detected