Skip to content

Commit

Permalink
fix(scripts): handle undefined action[command]
Browse files Browse the repository at this point in the history
  • Loading branch information
snickbit committed Jul 24, 2023
1 parent 1481934 commit ee13c71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env zx
import {pnpm, RunOptions} from './lib/pnpm'
import {debug, error, info, title, warn} from './lib/output'
import {debug, die, error, info, title, warn} from './lib/output'
import 'zx/globals'

$.verbose = argv.verbose || argv.v
Expand Down Expand Up @@ -107,7 +107,7 @@ async function handleCommandAction(commandAction: string) {
}

if (!(commandAction in actionMap)) {
error`Unknown action: ${commandAction}`
error`Unknown action: ${commandAction}. Available actions: ${Object.keys(actionMap).join(', ')}`
return
}

Expand All @@ -129,6 +129,10 @@ async function handleCommandAction(commandAction: string) {
}

async function runAction(commandAction: string) {
if (!actionMap[commandAction]) {
die`No action found for ${commandAction}. Available actions: ${Object.keys(actionMap).join(', ')}`
}

console.log('')
title`Command: ${chalk.cyan(commandAction)}`

Expand Down

0 comments on commit ee13c71

Please sign in to comment.