MCPcopy
hub / github.com/coder/mux / runRunDirect

Function runRunDirect

src/cli/run.test.ts:86–116  ·  view source on GitHub ↗

* Run run.ts directly with stdin closed to avoid hanging. * Passes empty stdin to simulate non-TTY invocation without input.

(args: string[], timeoutMs = 5000)

Source from the content-addressed store, hash-verified

84 * Passes empty stdin to simulate non-TTY invocation without input.
85 */
86async function runRunDirect(args: string[], timeoutMs = 5000): Promise<ExecResult> {
87 return new Promise((resolve) => {
88 const proc = spawn("bun", [RUN_PATH, ...args], {
89 timeout: timeoutMs,
90 env: { ...process.env, NO_COLOR: "1" },
91 stdio: ["pipe", "pipe", "pipe"], // stdin, stdout, stderr
92 });
93
94 let stdout = "";
95 let stderr = "";
96
97 proc.stdout?.on("data", (data: Buffer) => {
98 stdout += data.toString();
99 });
100
101 proc.stderr?.on("data", (data: Buffer) => {
102 stderr += data.toString();
103 });
104
105 // Close stdin immediately to prevent hanging on stdin.read()
106 proc.stdin?.end();
107
108 proc.on("close", (code) => {
109 resolve({ stdout, stderr, output: stdout + stderr, exitCode: code ?? 1 });
110 });
111
112 proc.on("error", () => {
113 resolve({ stdout, stderr, output: stdout + stderr, exitCode: 1 });
114 });
115 });
116}
117
118describe("mux CLI", () => {
119 beforeAll(() => {

Callers 1

run.test.tsFile · 0.85

Calls 3

onMethod · 0.80
resolveFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected