Skip to content

Commit 471fba2

Browse files
authoredJun 3, 2023
fix(create-vite): support bun as a script runner (#13402)
1 parent b28c847 commit 471fba2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎packages/create-vite/src/index.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,27 @@ async function init() {
324324

325325
if (customCommand) {
326326
const fullCustomCommand = customCommand
327-
.replace(/^npm create/, `${pkgManager} create`)
327+
.replace(/^npm create /, () => {
328+
// `bun create` uses it's own set of templates,
329+
// the closest alternative is using `bun x` directly on the package
330+
if (pkgManager === 'bun') {
331+
return 'bun x create-'
332+
}
333+
return `${pkgManager} create `
334+
})
328335
// Only Yarn 1.x doesn't support `@version` in the `create` command
329336
.replace('@latest', () => (isYarn1 ? '' : '@latest'))
330337
.replace(/^npm exec/, () => {
331-
// Prefer `pnpm dlx` or `yarn dlx`
338+
// Prefer `pnpm dlx`, `yarn dlx`, or `bun x`
332339
if (pkgManager === 'pnpm') {
333340
return 'pnpm dlx'
334341
}
335342
if (pkgManager === 'yarn' && !isYarn1) {
336343
return 'yarn dlx'
337344
}
345+
if (pkgManager === 'bun') {
346+
return 'bun x'
347+
}
338348
// Use `npm exec` in all other cases,
339349
// including Yarn 1.x and other custom npm clients.
340350
return 'npm exec'

0 commit comments

Comments
 (0)
Please sign in to comment.