Skip to content

Commit c263859

Browse files
committed
fix(upgrade): handle aborted nightly channel selection
1 parent b3f31de commit c263859

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/commands/upgrade.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ function hasPnpmWorkspaceFile(cwd: string): boolean {
4444
return existsSync(pnpmWorkspaceFilePath)
4545
}
4646

47+
const nuxtVersionTags = {
48+
'3.x': '3x',
49+
'4.x': 'latest',
50+
}
51+
4752
async function getNightlyVersion(packageNames: string[]): Promise<{ npmPackages: string[], nuxtVersion: string }> {
48-
const nuxtVersion = await consola.prompt(
53+
const result = await consola.prompt(
4954
'Which nightly Nuxt release channel do you want to install? (3.x or 4.x)',
5055
{
5156
type: 'select',
@@ -54,11 +59,9 @@ async function getNightlyVersion(packageNames: string[]): Promise<{ npmPackages:
5459
},
5560
) as '3.x' | '4.x'
5661

57-
const versions = {
58-
'3.x': '3x',
59-
'4.x': 'latest',
60-
}
61-
const npmPackages = packageNames.map(p => `${p}@npm:${p}-nightly@${versions[nuxtVersion]}`)
62+
const nuxtVersion = typeof result === 'string' ? result : '3.x'
63+
64+
const npmPackages = packageNames.map(p => `${p}@npm:${p}-nightly@${nuxtVersionTags[nuxtVersion]}`)
6265

6366
return { npmPackages, nuxtVersion }
6467
}

0 commit comments

Comments
 (0)