Page MenuHomeSealhub

exec.ts
No OneTemporary

/* eslint-disable no-console */
import { spawn } from "child_process";
export async function exec(
program: string,
args: string[]
): Promise<{ stderr: string; stdout: string; exitCode: number }> {
return new Promise((resolve, reject) => {
let stdout = "";
let stderr = "";
const process = spawn(program, args);
process.stdout.on(
"data",
(data: Buffer) => (stdout += data.toString())
);
process.stderr.on(
"data",
(data: Buffer) => (stderr += data.toString())
);
process.on("close", (exitCode) => {
if (exitCode === 0) {
resolve({ stdout, stderr, exitCode });
} else {
console.error([program, ...args].join(" "));
console.error(stderr);
reject({ stdout, stderr, exitCode });
}
});
});
}

File Metadata

Mime Type
text/x-java
Expires
Wed, May 7, 19:41 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
625093
Default Alt Text
exec.ts (748 B)

Event Timeline