Skip to content

Commit

Permalink
feat: exiut code 3 for no detected projects
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Sep 4, 2020
1 parent 945722f commit 9151ff0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/cli/index.ts
Expand Up @@ -43,6 +43,7 @@ const debug = Debug('snyk');
const EXIT_CODES = {
VULNS_FOUND: 1,
ERROR: 2,
NO_SUPPORTED_MANIFESTS_FOUND: 3,
};

async function runCommand(args: Args) {
Expand Down Expand Up @@ -89,6 +90,13 @@ async function handleError(args, error) {
spinner.clearAll();
let command = 'bad-command';
let exitCode = EXIT_CODES.ERROR;
const noSupportedManifestsFound = error.message?.includes(
'Could not detect supported target files in',
);

if (noSupportedManifestsFound) {
exitCode = EXIT_CODES.NO_SUPPORTED_MANIFESTS_FOUND;
}

const vulnsFound = error.code === 'VULNS';
if (vulnsFound) {
Expand Down
4 changes: 3 additions & 1 deletion src/lib/snyk-test/index.js
Expand Up @@ -51,7 +51,9 @@ function executeTest(root, options) {
return results;
});
} catch (error) {
return Promise.reject(chalk.red.bold(error));
return Promise.reject(
chalk.red.bold(error.message ? error.message : error),
);
}
}

Expand Down

0 comments on commit 9151ff0

Please sign in to comment.