From ee13c712dd215cbd3f273d8a4377ea40c2ac5411 Mon Sep 17 00:00:00 2001 From: Snickbit Date: Mon, 24 Jul 2023 14:18:29 -0400 Subject: [PATCH] fix(scripts): handle undefined action[command] --- scripts/src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/src/index.ts b/scripts/src/index.ts index 027ead18..e3c07a4c 100644 --- a/scripts/src/index.ts +++ b/scripts/src/index.ts @@ -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 @@ -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 } @@ -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)}`