Skip to content

Commit 4b56177

Browse files
Re-throw errors
1 parent 150e07f commit 4b56177

6 files changed

Lines changed: 15 additions & 6 deletions

File tree

lib/cli.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/cli.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ function parseGithubApiUrl(inputUrl: string): string {
4040
}
4141
}
4242

43+
const logger = getCLILogger();
44+
4345
program
4446
.command('upload')
4547
.description('Uploads a SARIF file, or all SARIF files from a directory, to code scanning')
@@ -51,7 +53,6 @@ program
5153
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
5254
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
5355
.action(async (cmd: UploadArgs) => {
54-
const logger = getCLILogger();
5556
try {
5657
await upload_lib.upload(
5758
cmd.sarifFile,
@@ -68,8 +69,9 @@ program
6869
'cli',
6970
logger);
7071
} catch (e) {
71-
logger.error("Upload failed");
72+
logger.error('Upload failed');
7273
logger.error(e);
74+
process.exitCode = 1;
7375
}
7476
});
7577

src/upload-lib.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ export async function upload(
139139
logger: Logger): Promise<UploadStatusReport> {
140140

141141
const sarifFiles: string[] = [];
142+
if (!fs.existsSync(sarifPath)) {
143+
throw new Error(`Path does not exist: ${sarifPath}`);
144+
}
142145
if (fs.lstatSync(sarifPath).isDirectory()) {
143146
fs.readdirSync(sarifPath)
144147
.filter(f => f.endsWith(".sarif"))

0 commit comments

Comments
 (0)