MCPcopy Index your code
hub / github.com/anomalyco/opencode / command

Function command

packages/tui/src/clipboard.ts:9–21  ·  view source on GitHub ↗
(command: string, args: string[] = [], input?: string)

Source from the content-addressed store, hash-verified

7const exec = promisify(execFile)
8
9function command(command: string, args: string[] = [], input?: string) {
10 return new Promise<Buffer>((resolve, reject) => {
11 const child = spawn(command, args, { stdio: [input === undefined ? "ignore" : "pipe", "pipe", "ignore"] })
12 const output: Buffer[] = []
13 child.on("error", reject)
14 child.stdout?.on("data", (chunk: Buffer) => output.push(chunk))
15 child.on("close", (code) => {
16 if (code === 0) return resolve(Buffer.concat(output))
17 reject(new Error(`${command} exited with code ${code}`))
18 })
19 if (input !== undefined) child.stdin?.end(input)
20 })
21}
22
23function writeOsc52(text: string) {
24 if (!process.stdout.isTTY) return

Callers 2

readFunction · 0.70
getCopyMethodFunction · 0.70

Calls 5

onMethod · 0.80
pushMethod · 0.80
spawnFunction · 0.50
resolveFunction · 0.50
rejectFunction · 0.50

Tested by

no test coverage detected