(a: string, b: string)
| 620 | } |
| 621 | |
| 622 | function compareVersions(a: string, b: string): number { |
| 623 | const parseVersion = (v: string) => { |
| 624 | const match = v.match(/^(\d+)\.(\d+)\.(\d+)/) |
| 625 | if (!match) return [0, 0, 0] |
| 626 | return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])] |
| 627 | } |
| 628 | |
| 629 | const [aMajor, aMinor, aPatch] = parseVersion(a) |
| 630 | const [bMajor, bMinor, bPatch] = parseVersion(b) |
| 631 | |
| 632 | if (aMajor !== bMajor) return aMajor - bMajor |
| 633 | if (aMinor !== bMinor) return aMinor - bMinor |
| 634 | return aPatch - bPatch |
| 635 | } |
no test coverage detected