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

Function callFork

src/main/core/ServiceVersionManager.ts:7–35  ·  view source on GitHub ↗
(
  forkManager: ForkManager,
  module: string,
  fn: string,
  ...args: any[]
)

Source from the content-addressed store, hash-verified

5const ALL_FLAGS: string[] = Object.values(AppModuleEnum)
6
7function callFork(
8 forkManager: ForkManager,
9 module: string,
10 fn: string,
11 ...args: any[]
12): Promise<any> {
13 return new Promise((resolve, reject) => {
14 let settled = false
15 forkManager
16 .send(module, fn, ...args)
17 .on(() => {
18 // 进度消息忽略
19 })
20 .then((res: any) => {
21 if (settled) return
22 settled = true
23 if (res?.code === 0) {
24 resolve(res?.data)
25 } else {
26 reject(new Error(typeof res?.msg === 'string' ? res.msg : 'fork call failed'))
27 }
28 })
29 .catch((e: any) => {
30 if (settled) return
31 settled = true
32 reject(e instanceof Error ? e : new Error(`${e}`))
33 })
34 })
35}
36
37/**
38 * ServiceVersionManager —— 主进程缓存各服务的已安装版本。

Callers 1

refreshMethod · 0.70

Calls 5

resolveFunction · 0.85
catchMethod · 0.80
thenMethod · 0.45
onMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected