Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore return code of npm audit fix #410

Merged
merged 3 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: ignore return code of npm audit fix
`npm audit fix` can return code `1` when no fix available.
  • Loading branch information
ybiquitous committed May 18, 2021
commit df4eca54d912cf602fa35cbce84ce53e0adad2f4
16 changes: 14 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9100,8 +9100,20 @@ exports.withCustomRequest = withCustomRequest;
const { exec } = __webpack_require__(986);
const npmArgs = __webpack_require__(510);

module.exports = function auditFix() {
return exec("npm", npmArgs("audit", "fix"));
module.exports = async function auditFix() {
let error = "";
await exec("npm", npmArgs("audit", "fix"), {
listeners: {
stderr: (data) => {
error += data.toString();
},
},
ignoreReturnCode: true,
});

if (error.includes("npm ERR!")) {
throw new Error("Unexpected error occured");
}
};


Expand Down
16 changes: 14 additions & 2 deletions lib/auditFix.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
const { exec } = require("@actions/exec");
const npmArgs = require("./npmArgs");

module.exports = function auditFix() {
return exec("npm", npmArgs("audit", "fix"));
module.exports = async function auditFix() {
let error = "";
await exec("npm", npmArgs("audit", "fix"), {
listeners: {
stderr: (data) => {
error += data.toString();
},
},
ignoreReturnCode: true,
});

if (error.includes("npm ERR!")) {
throw new Error("Unexpected error occured");
}
};