Skip to content

Commit 276f580

Browse files
committed
chore: always use detected package manager
1 parent c5c5f5d commit 276f580

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

packages/create-vite/src/index.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ async function init() {
512512
template = variant
513513
}
514514

515+
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
516+
515517
// 5. Ask about immediate install and package manager
516518
let immediate = argImmediate
517519
if (immediate === undefined) {
@@ -520,30 +522,13 @@ async function init() {
520522
immediate = false
521523
} else {
522524
const immediateResult = await prompts.confirm({
523-
message: 'Install and start now?',
525+
message: `Install with ${pkgManager} and start now?`,
524526
})
525527
if (prompts.isCancel(immediateResult)) return cancel()
526528
immediate = immediateResult
527529
}
528530
}
529531

530-
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
531-
let agent = 'npm'
532-
if (immediate) {
533-
const agentResult = await prompts.select({
534-
message: 'Select a package manager:',
535-
options: [
536-
{ label: 'npm', value: 'npm' },
537-
{ label: 'yarn', value: 'yarn' },
538-
{ label: 'pnpm', value: 'pnpm' },
539-
{ label: 'bun', value: 'bun' },
540-
],
541-
initialValue: pkgManager,
542-
})
543-
if (prompts.isCancel(agentResult)) return cancel()
544-
agent = agentResult
545-
}
546-
547532
const root = path.join(cwd, targetDir)
548533
fs.mkdirSync(root, { recursive: true })
549534

@@ -606,9 +591,8 @@ async function init() {
606591
}
607592

608593
if (immediate) {
609-
if (!agent) throw new Error()
610-
install(root, agent)
611-
start(root, agent)
594+
install(root, pkgManager)
595+
start(root, pkgManager)
612596
} else {
613597
let doneMessage = ''
614598
const cdProjectName = path.relative(cwd, root)

0 commit comments

Comments
 (0)