|
|
@ -4,13 +4,13 @@ import Emittery from "emittery";
|
|
|
|
export default function simpleSpawn(
|
|
|
|
export default function simpleSpawn(
|
|
|
|
cmd: string,
|
|
|
|
cmd: string,
|
|
|
|
arg: string[]
|
|
|
|
arg: string[]
|
|
|
|
): Promise<string> {
|
|
|
|
): Promise<{ stdout: string; stderr: string }> {
|
|
|
|
const process = spawn(cmd, arg);
|
|
|
|
const process = spawn(cmd, arg);
|
|
|
|
let output = "";
|
|
|
|
let output = "";
|
|
|
|
let err = "";
|
|
|
|
let err = "";
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
process.on("close", (code) => {
|
|
|
|
process.on("close", (code) => {
|
|
|
|
code === 0 ? resolve(output) : reject(err);
|
|
|
|
code === 0 ? resolve({ stdout: output, stderr: err }) : reject(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
process.stdout.on("data", (data) => (output += data.toString("utf-8")));
|
|
|
|
process.stdout.on("data", (data) => (output += data.toString("utf-8")));
|
|
|
|
process.stderr.on("data", (data) => (err += data.toString("utf-8")));
|
|
|
|
process.stderr.on("data", (data) => (err += data.toString("utf-8")));
|
|
|
|