From 934ea840f8b8c600e79e1b070aa2dd3a64f1053a Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Thu, 28 Sep 2023 18:01:17 +0530 Subject: [PATCH] refactor: log exit code in addition to the error message --- dist/index.js | 12 +++++++----- index.js | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index e7423fb..a13cf49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1858,13 +1858,13 @@ const exec = (cmd, args = []) => app.on("close", (code) => { if (code !== 0 && !stdout.includes("nothing to commit")) { - return reject({ code, message: stderr }); + return reject({ code, stderr }); } - return resolve({ code, stdout }); + return resolve(); }); - app.on("error", () => reject({ code: 1, message: stderr })); + app.on("error", () => reject({ code: 1, stderr })); }); /** @@ -1992,7 +1992,8 @@ Toolkit.run( try { await commitFile(); } catch (err) { - return tools.exit.failure(err.message); + const message = `Exit code: ${err.code}\n${err.stderr}`; + return tools.exit.failure(message); } tools.exit.success("Wrote to README"); } @@ -2042,7 +2043,8 @@ Toolkit.run( try { await commitFile(); } catch (err) { - return tools.exit.failure(err.message); + const message = `Exit code: ${err.code}\n${err.stderr}`; + return tools.exit.failure(message); } tools.exit.success("Pushed to remote repository"); }, diff --git a/index.js b/index.js index f613300..40d573a 100644 --- a/index.js +++ b/index.js @@ -75,13 +75,13 @@ const exec = (cmd, args = []) => app.on("close", (code) => { if (code !== 0 && !stdout.includes("nothing to commit")) { - return reject({ code, message: stderr }); + return reject({ code, stderr }); } - return resolve({ code, stdout }); + return resolve(); }); - app.on("error", () => reject({ code: 1, message: stderr })); + app.on("error", () => reject({ code: 1, stderr })); }); /** @@ -209,7 +209,8 @@ Toolkit.run( try { await commitFile(); } catch (err) { - return tools.exit.failure(err.message); + const message = `Exit code: ${err.code}\n${err.stderr}`; + return tools.exit.failure(message); } tools.exit.success("Wrote to README"); } @@ -259,7 +260,8 @@ Toolkit.run( try { await commitFile(); } catch (err) { - return tools.exit.failure(err.message); + const message = `Exit code: ${err.code}\n${err.stderr}`; + return tools.exit.failure(message); } tools.exit.success("Pushed to remote repository"); },