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

Function parseVersion

apps/cli/src/commands/cli/upgrade.ts:16–39  ·  view source on GitHub ↗
(version: string)

Source from the content-addressed store, hash-verified

14}
15
16function 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:

Callers 1

compareVersionsFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected