Skip to content

Commit

Permalink
fix: add run to build command when using bun (#615)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hornwitser authored Nov 19, 2024
1 parent c616f9e commit 23c29ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions __test__/getCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
5 changes: 5 additions & 0 deletions utils/getCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 23c29ee

Please sign in to comment.