From 92d4248b92a0772afc10739296b77e0798225f83 Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Tue, 26 Sep 2023 13:24:05 +0530 Subject: [PATCH] chore: better error logs --- dist/index.js | 22 +++++++++++++--------- index.js | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/dist/index.js b/dist/index.js index f89b554..387de49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1840,20 +1840,24 @@ const toUrlFormat = (item) => { const exec = (cmd, args = []) => new Promise((resolve, reject) => { - const app = spawn(cmd, args, { stdio: "pipe" }); + const app = spawn(cmd, args, { stdio: "inherit" }); + let stdout = ""; - app.stdout.on("data", (data) => { - stdout = data; - }); + if (app.stdout) { + app.stdout.on("data", (data) => { + stdout = data; + }); + } + app.on("close", (code) => { if (code !== 0 && !stdout.includes("nothing to commit")) { - err = new Error(`Invalid status code: ${code}`); - err.code = code; - return reject(err); + return reject({ code, stdout }); } - return resolve(code); + + return resolve({ code, stdout }); }); - app.on("error", reject); + + app.on("error", () => reject({ code, stdout })); }); /** diff --git a/index.js b/index.js index 7b27274..6121aab 100644 --- a/index.js +++ b/index.js @@ -57,20 +57,24 @@ const toUrlFormat = (item) => { const exec = (cmd, args = []) => new Promise((resolve, reject) => { - const app = spawn(cmd, args, { stdio: "pipe" }); + const app = spawn(cmd, args, { stdio: "inherit" }); + let stdout = ""; - app.stdout.on("data", (data) => { - stdout = data; - }); + if (app.stdout) { + app.stdout.on("data", (data) => { + stdout = data; + }); + } + app.on("close", (code) => { if (code !== 0 && !stdout.includes("nothing to commit")) { - err = new Error(`Invalid status code: ${code}`); - err.code = code; - return reject(err); + return reject({ code, stdout }); } - return resolve(code); + + return resolve({ code, stdout }); }); - app.on("error", reject); + + app.on("error", () => reject({ code, stdout })); }); /**