Skip to content

Commit

Permalink
chore: better error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Sep 26, 2023
1 parent 762c517 commit 92d4248
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
22 changes: 13 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
});

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

/**
Expand Down

0 comments on commit 92d4248

Please sign in to comment.