MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / parseSemver

Function parseSemver

src/upgrade/index.ts:157–166  ·  view source on GitHub ↗
(version: string)

Source from the content-addressed store, hash-verified

155}
156
157export 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. */
169export function compareVersions(a: string, b: string): number {

Callers 4

canonicalVersionTagFunction · 0.90
upgrade.test.tsFile · 0.90
compareVersionsFunction · 0.85
verifyResolvedVersionFunction · 0.85

Calls 1

execMethod · 0.65

Tested by

no test coverage detected