Skip to content

Commit 23c29ee

Browse files
authored
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
1 parent c616f9e commit 23c29ee

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

__test__/getCommand.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ describe('getCommand', () => {
1717
expect(getCommand('pnpm', 'dev')).toBe('pnpm dev')
1818
expect(getCommand('pnpm', 'build')).toBe('pnpm build')
1919
})
20+
it('should generate the correct command for bun', () => {
21+
expect(getCommand('bun', 'install')).toBe('bun install')
22+
expect(getCommand('bun', 'dev')).toBe('bun dev')
23+
expect(getCommand('bun', 'build')).toBe('bun run build')
24+
})
2025
})

utils/getCommand.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ export default function getCommand(packageManager: string, scriptName: string, a
22
if (scriptName === 'install') {
33
return packageManager === 'yarn' ? 'yarn' : `${packageManager} install`
44
}
5+
if (scriptName === 'build') {
6+
return packageManager === 'npm' || packageManager === 'bun'
7+
? `${packageManager} run build`
8+
: `${packageManager} build`
9+
}
510

611
if (args) {
712
return packageManager === 'npm'

0 commit comments

Comments
 (0)