import { spawn } from "child_process"; export function checkOutput(command: Array): Promise { const [prog, ...args] = command; return new Promise((resolve, reject) => { const proc = spawn(prog, args, { env: process.env, stdio: ["ignore", "pipe", "inherit"], }); proc.on("error", reject); let output = ""; proc.stdout.on("data", (chunk) => { output += chunk.toString(); }); proc.on("close", (code) => { if (code !== 0) { reject(new Error(`${prog} exited with code ${code}`)); return; } resolve(output); }); }); }