-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c790d2
commit ed0ef62
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,11 @@ Parameters: | |
PR number <int>: If left out, interactive picker is shown | ||
`.trim() | ||
|
||
function printHelpAndExit() { | ||
console.log(HELP) | ||
Deno.exit() | ||
} | ||
|
||
// inspired by: https://github.com/dsherret/dax/issues/137#issuecomment-1603848769 | ||
declare module 'https://deno.land/x/[email protected]/mod.ts' { | ||
interface CommandBuilder { | ||
|
@@ -55,8 +60,7 @@ async function pickPr() { | |
|
||
const prNum = await listPRs().pipe(picker()).pipe(cut()).text() | ||
if (!/^\d+$/.test(prNum)) { | ||
console.error(`Error picking PR. Expected number, got '${prNum}'`) | ||
Deno.exit() | ||
throw new Error(`Error picking PR. Expected number, got '${prNum}'`) | ||
} | ||
return parseInt(prNum, 10) | ||
} | ||
|
@@ -101,16 +105,12 @@ const args = flags.parse(Deno.args, { | |
boolean: ['force', 'help'], | ||
}) | ||
|
||
if (args.help) { | ||
console.log(HELP) | ||
Deno.exit() | ||
} | ||
if (args.help) printHelpAndExit() | ||
|
||
const prNum = args._[0] ? args._[0] : await pickPr() | ||
|
||
if (typeof prNum !== 'number') { | ||
console.error(`PR number must be a number. Got '${prNum}' instead.`) | ||
Deno.exit() | ||
throw new Error(`PR number must be a number. Got '${prNum}' instead.`) | ||
} | ||
|
||
const { base, head } = await getPrRange(prNum) | ||
|