Skip to content

Commit

Permalink
chore: move under others
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Sep 23, 2022
1 parent 13f7b9d commit a567995
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/create-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ type Framework = {
name: string
display: string
color: ColorFunc
customCommand?: string
variants?: FrameworkVariant[]
variants: FrameworkVariant[]
}
type FrameworkVariant = {
name: string
Expand Down Expand Up @@ -164,7 +163,14 @@ const FRAMEWORKS: Framework[] = [
name: 'others',
display: 'Others',
color: reset,
customCommand: 'npm create vite-extra@latest TARGET_DIR'
variants: [
{
name: 'create-vite-extra',
display: 'create-vite-extra',
color: reset,
customCommand: 'npm create vite-extra@latest TARGET_DIR'
}
]
}
]

Expand Down Expand Up @@ -254,7 +260,7 @@ async function init() {
name: 'variant',
message: reset('Select a variant:'),
choices: (framework: Framework) =>
framework.variants?.map((variant) => {
framework.variants.map((variant) => {
const variantColor = variant.color
return {
title: variantColor(variant.display || variant.name),
Expand Down Expand Up @@ -292,10 +298,8 @@ async function init() {
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
const isYarn1 = pkgManager === 'yarn' && pkgInfo?.version.startsWith('1.')

const customCommand =
FRAMEWORKS.find((f) => f.name === template)?.customCommand ??
FRAMEWORKS.flatMap((f) => f.variants).find((v) => v?.name === template)
?.customCommand
const { customCommand } =
FRAMEWORKS.flatMap((f) => f.variants).find((v) => v.name === template) ?? {}

if (customCommand) {
const fullCustomCommand = customCommand
Expand Down

0 comments on commit a567995

Please sign in to comment.