MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / runCommand

Function runCommand

tests/release-bootstrap-smoke.test.ts:24–57  ·  view source on GitHub ↗
(
  command: string,
  args: ReadonlyArray<string>,
  cwd: string,
  env: NodeJS.ProcessEnv = process.env,
)

Source from the content-addressed store, hash-verified

22}
23
24const runCommand = async (
25 command: string,
26 args: ReadonlyArray<string>,
27 cwd: string,
28 env: NodeJS.ProcessEnv = process.env,
29): Promise<CommandResult> => {
30 const child = spawn(command, [...args], {
31 cwd,
32 env,
33 stdio: ["ignore", "pipe", "pipe"],
34 });
35
36 let stdout = "";
37 let stderr = "";
38
39 child.stdout.setEncoding("utf8");
40 child.stdout.on("data", (chunk) => {
41 stdout += chunk;
42 });
43
44 child.stderr.setEncoding("utf8");
45 child.stderr.on("data", (chunk) => {
46 stderr += chunk;
47 });
48
49 const exitCode = await new Promise<number>((resolveExitCode, reject) => {
50 child.once("error", reject);
51 child.once("close", (code) => {
52 resolveExitCode(code ?? -1);
53 });
54 });
55
56 return { exitCode, stdout, stderr };
57};
58
59const listen = async (server: ReturnType<typeof createServer>): Promise<number> =>
60 Effect.runPromise(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected