]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
fix: add run to build command when using bun (#615)
authorHornwitser <github@hornwitser.no>
Tue, 19 Nov 2024 13:59:27 +0000 (14:59 +0100)
committerGitHub <noreply@github.com>
Tue, 19 Nov 2024 13:59:27 +0000 (14:59 +0100)
If the package manager is bun and the command is build generate 'bun run
build' as the command to invoke the build script instead of the built-in
'bun build' command.

Fixes #614

__test__/getCommand.spec.ts
utils/getCommand.ts

index 63c86a99d7f36c0d95f0cd4904d23d8d2153fd15..6730da93b981e5b19e92e8516c23442f9a6737a6 100644 (file)
@@ -17,4 +17,9 @@ describe('getCommand', () => {
     expect(getCommand('pnpm', 'dev')).toBe('pnpm dev')
     expect(getCommand('pnpm', 'build')).toBe('pnpm build')
   })
+  it('should generate the correct command for bun', () => {
+    expect(getCommand('bun', 'install')).toBe('bun install')
+    expect(getCommand('bun', 'dev')).toBe('bun dev')
+    expect(getCommand('bun', 'build')).toBe('bun run build')
+  })
 })
index ea3a4e1987dba7b70f9dc17e4f8163c503a5d0cb..40b907d8e2c1365f203d623fbba1910848751e49 100644 (file)
@@ -2,6 +2,11 @@ export default function getCommand(packageManager: string, scriptName: string, a
   if (scriptName === 'install') {
     return packageManager === 'yarn' ? 'yarn' : `${packageManager} install`
   }
+  if (scriptName === 'build') {
+    return packageManager === 'npm' || packageManager === 'bun'
+      ? `${packageManager} run build`
+      : `${packageManager} build`
+  }
 
   if (args) {
     return packageManager === 'npm'