Skip to content

Commit

Permalink
fix(create-app): prompt the user on supplying an invalid template (#2072
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jamesgeorge007 authored Feb 18, 2021
1 parent d0eac2f commit ea31690
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/create-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,21 @@ async function init() {

// determine template
let template = argv.t || argv.template
if (!template) {

const availableTemplates = TEMPLATES.map((template) => stripColors(template))
const isValidTemplate = availableTemplates.includes(template)
const message = isValidTemplate
? `Select a template:`
: `${template} isn't a valid template. Please choose from below: `

if (!template || !isValidTemplate) {
/**
* @type {{ t: string }}
*/
const { t } = await prompt({
type: 'select',
name: 't',
message: `Select a template:`,
message,
choices: TEMPLATES
})
template = stripColors(t)
Expand Down

0 comments on commit ea31690

Please sign in to comment.