MCPcopy Index your code
hub / github.com/actions/starter-workflows / exec

Function exec

script/sync-ghes/exec.ts:11–42  ·  view source on GitHub ↗
(
  command: string,
  args: string[] = [],
  allowAllExitCodes: boolean = false
)

Source from the content-addressed store, hash-verified

9 * Executes a process
10 */
11export async function exec(
12 command: string,
13 args: string[] = [],
14 allowAllExitCodes: boolean = false
15): Promise<ExecResult> {
16 process.stdout.write(`EXEC: ${command} ${args.join(" ")}\n`);
17 return new Promise((resolve, reject) => {
18 const execResult = new ExecResult();
19 const cp = spawn(command, args, {});
20
21 // STDOUT
22 cp.stdout.on("data", (data) => {
23 process.stdout.write(data);
24 execResult.stdout += data.toString();
25 });
26
27 // STDERR
28 cp.stderr.on("data", (data) => {
29 process.stderr.write(data);
30 });
31
32 // Close
33 cp.on("close", (code) => {
34 execResult.exitCode = code;
35 if (code === 0 || allowAllExitCodes) {
36 resolve(execResult);
37 } else {
38 reject(new Error(`Command exited with code ${code}`));
39 }
40 });
41 });
42}

Callers 1

index.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected