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 dbd3749
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
29 changes: 20 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1840,20 +1840,31 @@ 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;
});
}

let stderr = "";
if (app.stderr) {
app.stderr.on("data", (data) => {
stderr = 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, stderr });
}
return resolve(code);

return resolve({ code, stdout });
});
app.on("error", reject);

app.on("error", () => reject({ code, stderr }));
});

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

let stderr = "";
if (app.stderr) {
app.stderr.on("data", (data) => {
stderr = 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, stderr });
}
return resolve(code);

return resolve({ code, stdout });
});
app.on("error", reject);

app.on("error", () => reject({ code, stderr }));
});

/**
Expand Down

0 comments on commit dbd3749

Please sign in to comment.