MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / fetchLatestVersion

Function fetchLatestVersion

lib/update.ts:130–146  ·  view source on GitHub ↗
(name: string, signal: AbortSignal)

Source from the content-addressed store, hash-verified

128}
129
130async function fetchLatestVersion(name: string, signal: AbortSignal) {
131 try {
132 const response = await fetch(
133 `https://registry.npmjs.org/${encodeURIComponent(name)}/latest`,
134 {
135 signal,
136 },
137 )
138 if (!response.ok) return undefined
139 const data: unknown = await response.json()
140 if (!data || typeof data !== "object") return undefined
141 const version = (data as { version?: unknown }).version
142 return typeof version === "string" ? version : undefined
143 } catch {
144 return undefined
145 }
146}
147
148export function isVersionNewer(latest: string, current: string) {
149 const next = parseVersion(latest)

Callers 1

checkAutoUpdateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected