Skip to content

Commit

Permalink
feat: better vulnerability report retrieval errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed May 10, 2023
1 parent 4c27831 commit 2ce3e10
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/issues/vulnerabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const fromNpm = (appPath, packageGraph) =>

resolve(reports);
} catch (error) {
reject(error);
reject(new Error(`${error.message} => ${stdout}`));
}
}
});
Expand Down Expand Up @@ -112,7 +112,7 @@ const fromYarnOrPnpm = (appPath, packageGraph, usePnpm = false) =>

resolve(reports);
} catch (error) {
reject(error);
reject(new Error(`${error.message} => ${stdout}`));
}
}
},
Expand All @@ -131,18 +131,22 @@ const getDependencyVulnerabilities = async ({
}) => {
let vulnerabilities;

if (packageManager === 'npm') {
onProgress('Getting vulnerability report from npm');
vulnerabilities = await fromNpm(appPath, packageGraph);
} else if (packageManager === 'yarn-classic') {
onProgress('Getting vulnerability report from yarn');
vulnerabilities = await fromYarnClassic(appPath, packageGraph);
} else if (packageManager === 'yarn') {
onProgress('Getting vulnerability report from yarn');
vulnerabilities = await fromYarn(appPath, packageGraph);
} else if (packageManager === 'pnpm') {
onProgress('Getting vulnerability report from pnpm');
vulnerabilities = await fromPnpm(appPath, packageGraph);
try {
if (packageManager === 'npm') {
onProgress('Getting vulnerability report from npm');
vulnerabilities = await fromNpm(appPath, packageGraph);
} else if (packageManager === 'yarn-classic') {
onProgress('Getting vulnerability report from yarn');
vulnerabilities = await fromYarnClassic(appPath, packageGraph);
} else if (packageManager === 'yarn') {
onProgress('Getting vulnerability report from yarn');
vulnerabilities = await fromYarn(appPath, packageGraph);
} else if (packageManager === 'pnpm') {
onProgress('Getting vulnerability report from pnpm');
vulnerabilities = await fromPnpm(appPath, packageGraph);
}
} catch (error) {
throw new Error(`Error getting vulnerability report from ${packageManager}: ${error.message}`);
}

return vulnerabilities;
Expand Down

0 comments on commit 2ce3e10

Please sign in to comment.