(version: string)
| 155 | } |
| 156 | |
| 157 | export function parseSemver(version: string): Semver | null { |
| 158 | const m = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(version.trim()); |
| 159 | if (!m) return null; |
| 160 | return { |
| 161 | major: parseInt(m[1]!, 10), |
| 162 | minor: parseInt(m[2]!, 10), |
| 163 | patch: parseInt(m[3]!, 10), |
| 164 | pre: m[4] ?? null, |
| 165 | }; |
| 166 | } |
| 167 | |
| 168 | /** Returns >0 if a>b, <0 if a<b, 0 if equal. Throws on unparseable input. */ |
| 169 | export function compareVersions(a: string, b: string): number { |
no test coverage detected