MCPcopy
hub / github.com/xpf0000/FlyEnv / resolveVersionObj

Method resolveVersionObj

src/main/core/MCPContextResolver.ts:276–298  ·  view source on GitHub ↗
(flag: string, version?: string)

Source from the content-addressed store, hash-verified

274 }
275
276 private async resolveVersionObj(flag: string, version?: string) {
277 const installed = await this.rawServiceVersions(flag)
278 if (!installed.length) {
279 throw new Error(`No installed version for ${flag}`)
280 }
281 if (version) {
282 const exact = installed.find((item) => item?.version === version)
283 if (!exact) {
284 throw new Error(`Version ${version} of ${flag} not found`)
285 }
286 return exact
287 }
288 const status = ServiceProcessManager.statusOf(flag)
289 if (status.instances.length > 0) {
290 const running = installed.find((item) =>
291 status.instances.some((instance) => instance.bin === item.bin)
292 )
293 if (running) {
294 return running
295 }
296 }
297 return installed.find((item) => item?.enable) ?? installed[0]
298 }
299
300 private async listConfigFiles(flag: string, version?: SoftInstalled) {
301 const list = await callFork(this.forkManager, flag, 'listConfigFiles', version)

Callers 3

getServiceExecInfoMethod · 0.95
getManagedFileMapMethod · 0.95

Calls 2

rawServiceVersionsMethod · 0.95
statusOfMethod · 0.80

Tested by

no test coverage detected