From 23c29eed0ee02891331e8cfba4c3c2f799031e01 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Tue, 19 Nov 2024 14:59:27 +0100 Subject: [PATCH] fix: add run to build command when using bun (#615) 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 | 5 +++++ utils/getCommand.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/__test__/getCommand.spec.ts b/__test__/getCommand.spec.ts index 63c86a99..6730da93 100644 --- a/__test__/getCommand.spec.ts +++ b/__test__/getCommand.spec.ts @@ -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') + }) }) diff --git a/utils/getCommand.ts b/utils/getCommand.ts index ea3a4e19..40b907d8 100644 --- a/utils/getCommand.ts +++ b/utils/getCommand.ts @@ -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' -- 2.39.5