From 96eb7ae979c229801bf62435391021be4c0fb667 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Sun, 17 Nov 2024 17:10:10 +0100 Subject: [PATCH] Add run to build command when using bun 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. --- __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 63c86a99d..6730da93b 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 ea3a4e198..40b907d8e 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'