Page MenuHomeSealhub

exec.ts
No OneTemporary

Authored By
Unknown
Size
728 B
Referenced Files
None
Subscribers
None
/* 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
application/javascript
Expires
Fri, Nov 27, 17:24 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1200222
Default Alt Text
exec.ts (728 B)

Event Timeline