MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / compareVersions

Function compareVersions

apps/cli/src/commands/cli/upgrade.ts:47–66  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

45 * - -1 when `a < b`
46 */
47export function compareVersions(a: string, b: string): number {
48 const aParts = parseVersion(a)
49 const bParts = parseVersion(b)
50 const maxLength = Math.max(aParts.length, bParts.length)
51
52 for (let i = 0; i < maxLength; i++) {
53 const aPart = aParts[i] ?? 0
54 const bPart = bParts[i] ?? 0
55
56 if (aPart > bPart) {
57 return 1
58 }
59
60 if (aPart < bPart) {
61 return -1
62 }
63 }
64
65 return 0
66}
67
68export async function getLatestCliVersion(fetchImpl: typeof fetch = fetch): Promise<string> {
69 const response = await fetchImpl(RELEASES_URL, {

Callers 3

getLatestCliVersionFunction · 0.85
upgradeFunction · 0.85
upgrade.test.tsFile · 0.85

Calls 1

parseVersionFunction · 0.85

Tested by

no test coverage detected