From 931ec17e23146a605d2f98761ef213abeb637a99 Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 1 Jun 2023 22:33:18 -0400 Subject: [PATCH] support bun as a package manager in create-vite --- packages/create-vite/src/index.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/create-vite/src/index.ts b/packages/create-vite/src/index.ts index dfc9473e23ff55..47d9dab68cf9ca 100755 --- a/packages/create-vite/src/index.ts +++ b/packages/create-vite/src/index.ts @@ -324,17 +324,27 @@ async function init() { if (customCommand) { const fullCustomCommand = customCommand - .replace(/^npm create/, `${pkgManager} create`) + .replace(/^npm create /, () => { + // `bun create` uses it's own set of templates, + // the closest alternative is using `bun x` directly on the package + if (pkgManager === 'bun') { + return 'bun x create-' + } + return `${pkgManager} create ` + }) // Only Yarn 1.x doesn't support `@version` in the `create` command .replace('@latest', () => (isYarn1 ? '' : '@latest')) .replace(/^npm exec/, () => { - // Prefer `pnpm dlx` or `yarn dlx` + // Prefer `pnpm dlx`, `yarn dlx`, or `bun x` if (pkgManager === 'pnpm') { return 'pnpm dlx' } if (pkgManager === 'yarn' && !isYarn1) { return 'yarn dlx' } + if (pkgManager === 'bun') { + return 'bun x' + } // Use `npm exec` in all other cases, // including Yarn 1.x and other custom npm clients. return 'npm exec'