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
Fri, Jan 24, 15:16 (17 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599981
Default Alt Text
exec.ts (748 B)

Event Timeline