Skip to content

Commit ed0ef62

Browse files
committed
minor tweaks to api-diff script
1 parent 1c790d2 commit ed0ef62

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tools/deno/api-diff.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Parameters:
3131
PR number <int>: If left out, interactive picker is shown
3232
`.trim()
3333

34+
function printHelpAndExit() {
35+
console.log(HELP)
36+
Deno.exit()
37+
}
38+
3439
// inspired by: https://github.com/dsherret/dax/issues/137#issuecomment-1603848769
3540
declare module 'https://deno.land/x/dax@0.35.0/mod.ts' {
3641
interface CommandBuilder {
@@ -55,8 +60,7 @@ async function pickPr() {
5560

5661
const prNum = await listPRs().pipe(picker()).pipe(cut()).text()
5762
if (!/^\d+$/.test(prNum)) {
58-
console.error(`Error picking PR. Expected number, got '${prNum}'`)
59-
Deno.exit()
63+
throw new Error(`Error picking PR. Expected number, got '${prNum}'`)
6064
}
6165
return parseInt(prNum, 10)
6266
}
@@ -101,16 +105,12 @@ const args = flags.parse(Deno.args, {
101105
boolean: ['force', 'help'],
102106
})
103107

104-
if (args.help) {
105-
console.log(HELP)
106-
Deno.exit()
107-
}
108+
if (args.help) printHelpAndExit()
108109

109110
const prNum = args._[0] ? args._[0] : await pickPr()
110111

111112
if (typeof prNum !== 'number') {
112-
console.error(`PR number must be a number. Got '${prNum}' instead.`)
113-
Deno.exit()
113+
throw new Error(`PR number must be a number. Got '${prNum}' instead.`)
114114
}
115115

116116
const { base, head } = await getPrRange(prNum)

0 commit comments

Comments
 (0)