(version: string)
| 14 | } |
| 15 | |
| 16 | function parseVersion(version: string): number[] { |
| 17 | const cleaned = version |
| 18 | .trim() |
| 19 | .replace(/^cli-v/, "") |
| 20 | .replace(/^v/, "") |
| 21 | const core = cleaned.split("+", 1)[0]?.split("-", 1)[0] |
| 22 | |
| 23 | if (!core) { |
| 24 | throw new Error(`Invalid version: ${version}`) |
| 25 | } |
| 26 | |
| 27 | const parts = core.split(".") |
| 28 | if (parts.length === 0) { |
| 29 | throw new Error(`Invalid version: ${version}`) |
| 30 | } |
| 31 | |
| 32 | return parts.map((part) => { |
| 33 | if (!/^\d+$/.test(part)) { |
| 34 | throw new Error(`Invalid version: ${version}`) |
| 35 | } |
| 36 | |
| 37 | return Number.parseInt(part, 10) |
| 38 | }) |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns: |
no test coverage detected