bombshell-dev / clack

Effortlessly build beautiful command-line apps
https://clack.cc
5.25k stars 88 forks source link

[Bug] `SelectPrompt` throws a `TypeError` when given an empty options array #144

Open kevduc opened 10 months ago

kevduc commented 10 months ago

Environment

Describe the bug SelectPrompt throws a TypeError when given an empty options array.
Encountered when using @sentry/wizard@3.9.2, see the related issue: https://github.com/getsentry/sentry-wizard/issues/400

Example:

TypeError: Cannot read properties of undefined (reading 'value')
    at SelectPrompt.changeValue (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3567)
    at new SelectPrompt (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3235)

To Reproduce https://stackblitz.com/edit/node-kyd3oq?file=index.ts

Pass an empty array for options when creating a new SelectPrompt

Expected behavior SelectPrompt (and select from @clack/prompts) should require at least 1 element in the array (it doesn't make sense to have no options to select from)