MCPcopy
hub / github.com/anomalyco/opencode / run

Function run

packages/core/test/util/flock.test.ts:62–82  ·  view source on GitHub ↗
(msg: Msg)

Source from the content-addressed store, hash-verified

60}
61
62function run(msg: Msg) {
63 return new Promise<{ code: number; stdout: Buffer; stderr: Buffer }>((resolve) => {
64 const proc = spawn(process.execPath, [worker, JSON.stringify(msg)], {
65 cwd: root,
66 })
67
68 const stdout: Buffer[] = []
69 const stderr: Buffer[] = []
70
71 proc.stdout?.on("data", (data) => stdout.push(Buffer.from(data)))
72 proc.stderr?.on("data", (data) => stderr.push(Buffer.from(data)))
73
74 proc.on("close", (code) => {
75 resolve({
76 code: code ?? 1,
77 stdout: Buffer.concat(stdout),
78 stderr: Buffer.concat(stderr),
79 })
80 })
81 })
82}
83
84function spawnWorker(msg: Msg) {
85 return spawn(process.execPath, [worker, JSON.stringify(msg)], {

Callers 1

flock.test.tsFile · 0.70

Calls 5

onMethod · 0.80
pushMethod · 0.80
spawnFunction · 0.50
resolveFunction · 0.50
fromMethod · 0.45

Tested by

no test coverage detected