From 7ee6a21f38834b0a40f75a190e1bbfd0a2b01ead Mon Sep 17 00:00:00 2001 From: Kuba Orlik Date: Thu, 25 Mar 2021 17:55:27 +0100 Subject: [PATCH] Include stderr in simplespawner output --- package.json | 2 +- src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 512ffca..5af7139 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "async-spawner", - "version": "0.1.6", + "version": "0.1.7", "description": "Simple process spawning utility for node.js", "main": "./lib/index.js", "types": "./@types/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 6f9c0be..90e9e2f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,13 +4,13 @@ import Emittery from "emittery"; export default function simpleSpawn( cmd: string, arg: string[] -): Promise { +): Promise<{ stdout: string; stderr: string }> { const process = spawn(cmd, arg); let output = ""; let err = ""; return new Promise((resolve, reject) => { 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.stderr.on("data", (data) => (err += data.toString("utf-8")));