Skip to content

Commit 1ae29bc

Browse files
authored
chore(cli): add support for bun package manager (#422)
1 parent 79fda1b commit 1ae29bc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/cli/src/node/packageManager.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { promisify } from 'util'
33

44
const execPromise = promisify(exec)
55

6-
export const PACKAGE_MANAGER_TYPES = ['pnpm', 'yarn', 'npm'] as const
6+
export const PACKAGE_MANAGER_TYPES = ['pnpm', 'bun', 'yarn', 'npm'] as const
77

88
export type PackageManagerType = (typeof PACKAGE_MANAGER_TYPES)[number]
99

@@ -30,6 +30,10 @@ export async function selectPackageManager(): Promise<PackageManager> {
3030
return createPnpm()
3131
}
3232

33+
if (await isPackageManagerAvailable('bun')) {
34+
return createRunner({ type: 'bun' })
35+
}
36+
3337
if (await isPackageManagerAvailable('npm')) {
3438
return createNpm()
3539
}
@@ -45,6 +49,7 @@ export async function selectPackageManager(): Promise<PackageManager> {
4549

4650
export function getPackageManager(type: PackageManagerType) {
4751
if (type === 'pnpm') return createPnpm()
52+
if (type === 'bun') return createBun()
4853
if (type === 'yarn') return createYarn()
4954
if (type === 'npm') return createNpm()
5055
throw new Error(`Unknown package manager ${type as string}.`)
@@ -62,6 +67,10 @@ function createNpm(): PackageManager {
6267
return createRunner({ type: 'npm', installArgs: ['--legacy-peer-deps'] })
6368
}
6469

70+
function createBun(): PackageManager {
71+
return createRunner({ type: 'bun' })
72+
}
73+
6574
function createRunner({
6675
type,
6776
installArgs,

packages/starters/carbon-multi-page/src/routes/+layout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ setupMarkedExtensions()
3535
// Alllows custom commands to highlight in shell syntax
3636
Prism.languages.insertBefore('shell', 'function', {
3737
keyword: {
38-
pattern: /(^\s*)(?:magidoc|pnpm|npm|yarn)(?=\s)/m,
38+
pattern: /(^\s*)(?:magidoc|pnpm|npm|yarn|bun)(?=\s)/m,
3939
lookbehind: true,
4040
},
4141
})

0 commit comments

Comments
 (0)