openai/codex-action

Public

mirrored from https://github.com/openai/codex-actionAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v1.9

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/checkOutput.ts

27lines · modecode

1import { spawn } from "child_process";
2
3export function checkOutput(command: Array<string>): Promise<string> {
4 const [prog, ...args] = command;
5 return new Promise<string>((resolve, reject) => {
6 const proc = spawn(prog, args, {
7 env: process.env,
8 stdio: ["ignore", "pipe", "inherit"],
9 });
10
11 proc.on("error", reject);
12
13 let output = "";
14 proc.stdout.on("data", (chunk) => {
15 output += chunk.toString();
16 });
17
18 proc.on("close", (code) => {
19 if (code !== 0) {
20 reject(new Error(`${prog} exited with code ${code}`));
21 return;
22 }
23
24 resolve(output);
25 });
26 });
27}
28