Skip to content

Commit a50a162

Browse files
authored
fix(create-vite): support deno create command (#20806)
1 parent 9f2247c commit a50a162

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

packages/create-vite/src/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,10 @@ function getFullCustomCommand(customCommand: string, pkgInfo?: PkgInfo) {
658658
if (pkgManager === 'bun') {
659659
return 'bun x create-'
660660
}
661+
// Deno uses `run -A npm:create-` instead of `create` or `init` to also provide needed perms
662+
if (pkgManager === 'deno') {
663+
return 'deno run -A npm:create-'
664+
}
661665
// pnpm doesn't support the -- syntax
662666
if (pkgManager === 'pnpm') {
663667
return 'pnpm create '
@@ -669,20 +673,23 @@ function getFullCustomCommand(customCommand: string, pkgInfo?: PkgInfo) {
669673
})
670674
// Only Yarn 1.x doesn't support `@version` in the `create` command
671675
.replace('@latest', () => (isYarn1 ? '' : '@latest'))
672-
.replace(/^npm exec/, () => {
676+
.replace(/^npm exec /, () => {
673677
// Prefer `pnpm dlx`, `yarn dlx`, or `bun x`
674678
if (pkgManager === 'pnpm') {
675-
return 'pnpm dlx'
679+
return 'pnpm dlx '
676680
}
677681
if (pkgManager === 'yarn' && !isYarn1) {
678-
return 'yarn dlx'
682+
return 'yarn dlx '
679683
}
680684
if (pkgManager === 'bun') {
681-
return 'bun x'
685+
return 'bun x '
686+
}
687+
if (pkgManager === 'deno') {
688+
return 'deno run -A npm:'
682689
}
683690
// Use `npm exec` in all other cases,
684691
// including Yarn 1.x and other custom npm clients.
685-
return 'npm exec'
692+
return 'npm exec '
686693
})
687694
)
688695
}

0 commit comments

Comments
 (0)