Skip to content

Commit

Permalink
refactor: log exit code in addition to the error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored and tuunit committed Sep 29, 2023
1 parent e0d6a37 commit a38649b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
});

/**
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
},
Expand Down
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
});

/**
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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");
},
Expand Down

0 comments on commit a38649b

Please sign in to comment.