Fix spawn not resolving

master
Kuba Orlik 4 years ago
parent a3d1a2bc27
commit 77ff039406

@ -33,14 +33,11 @@ export class DeferedSpawn extends Emittery {
}
async waitForNextData(): Promise<string | null> {
console.log("waiting for next data from", this.process.spawnargs.join(" "));
return new Promise((resolve, reject) => {
this.on("data", (data) => {
console.log("got answer from process", this.process.spawnfile);
resolve(data.toString("utf-8"));
});
this.on("error", (err) => {
console.error("Rejecting from process", this.process.spawnfile, err);
reject(err);
});
this.on("end", () => resolve(null));
@ -83,13 +80,13 @@ export function deferedSpawn(
err += data.toString("utf-8");
});
process.on("spawn", () => {
spawned = true;
resolve(emitter);
});
process.on("close", (code) => {
if (!spawned) {
reject(err);
} else {
console.log("!!!!!!!!!!!!!!!!!!!! PROCESS CLOSED");
if (code === 0) {
emitter.emit("success", output);
} else {

Loading…
Cancel
Save