@@ -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
3540declare 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
109110const prNum = args . _ [ 0 ] ? args . _ [ 0 ] : await pickPr ( )
110111
111112if ( 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
116116const { base, head } = await getPrRange ( prNum )
0 commit comments