Skip to content

Commit

Permalink
fix(upgrade): handle aborted nightly channel selection
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 22, 2024
1 parent b3f31de commit c263859
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ function hasPnpmWorkspaceFile(cwd: string): boolean {
return existsSync(pnpmWorkspaceFilePath)
}

const nuxtVersionTags = {
'3.x': '3x',
'4.x': 'latest',
}

async function getNightlyVersion(packageNames: string[]): Promise<{ npmPackages: string[], nuxtVersion: string }> {
const nuxtVersion = await consola.prompt(
const result = await consola.prompt(
'Which nightly Nuxt release channel do you want to install? (3.x or 4.x)',
{
type: 'select',
Expand All @@ -54,11 +59,9 @@ async function getNightlyVersion(packageNames: string[]): Promise<{ npmPackages:
},
) as '3.x' | '4.x'

const versions = {
'3.x': '3x',
'4.x': 'latest',
}
const npmPackages = packageNames.map(p => `${p}@npm:${p}-nightly@${versions[nuxtVersion]}`)
const nuxtVersion = typeof result === 'string' ? result : '3.x'

const npmPackages = packageNames.map(p => `${p}@npm:${p}-nightly@${nuxtVersionTags[nuxtVersion]}`)

return { npmPackages, nuxtVersion }
}
Expand Down

0 comments on commit c263859

Please sign in to comment.