Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/cli/src/node/packageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const execPromise = promisify(exec)

export const PACKAGE_MANAGER_TYPES = ['pnpm', 'yarn', 'npm'] as const
export const PACKAGE_MANAGER_TYPES = ['pnpm', 'bun', 'yarn', 'npm'] as const

export type PackageManagerType = (typeof PACKAGE_MANAGER_TYPES)[number]

Expand All @@ -30,6 +30,10 @@
return createPnpm()
}

if (await isPackageManagerAvailable('bun')) {
return createRunner({ type: 'bun' })
}

Check warning on line 35 in packages/cli/src/node/packageManager.ts

View check run for this annotation

Codecov / codecov/patch

packages/cli/src/node/packageManager.ts#L33-L35

Added lines #L33 - L35 were not covered by tests

if (await isPackageManagerAvailable('npm')) {
return createNpm()
}
Expand All @@ -45,6 +49,7 @@

export function getPackageManager(type: PackageManagerType) {
if (type === 'pnpm') return createPnpm()
if (type === 'bun') return createBun()

Check warning on line 52 in packages/cli/src/node/packageManager.ts

View check run for this annotation

Codecov / codecov/patch

packages/cli/src/node/packageManager.ts#L52

Added line #L52 was not covered by tests
if (type === 'yarn') return createYarn()
if (type === 'npm') return createNpm()
throw new Error(`Unknown package manager ${type as string}.`)
Expand All @@ -62,6 +67,10 @@
return createRunner({ type: 'npm', installArgs: ['--legacy-peer-deps'] })
}

function createBun(): PackageManager {
return createRunner({ type: 'bun' })
}

Check warning on line 72 in packages/cli/src/node/packageManager.ts

View check run for this annotation

Codecov / codecov/patch

packages/cli/src/node/packageManager.ts#L70-L72

Added lines #L70 - L72 were not covered by tests

function createRunner({
type,
installArgs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ setupMarkedExtensions()
// Alllows custom commands to highlight in shell syntax
Prism.languages.insertBefore('shell', 'function', {
keyword: {
pattern: /(^\s*)(?:magidoc|pnpm|npm|yarn)(?=\s)/m,
pattern: /(^\s*)(?:magidoc|pnpm|npm|yarn|bun)(?=\s)/m,
lookbehind: true,
},
})
Expand Down
Loading