Skip to content

Commit

Permalink
feat(shadcn-cli): add support for bun install (#707)
Browse files Browse the repository at this point in the history
* add support for bun install

* fix(cli): add changeset for bun install

---------

Co-authored-by: shadcn <[email protected]>
  • Loading branch information
MarkLyck and shadcn committed Jun 27, 2023
1 parent a8bb2ef commit c337753
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-otters-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

fix(cli): use bun add when bun detected
4 changes: 2 additions & 2 deletions packages/cli/src/utils/get-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { detect } from "@antfu/ni"

export async function getPackageManager(
targetDir: string
): Promise<"yarn" | "pnpm" | "npm"> {
): Promise<"yarn" | "pnpm" | "bun" | "npm"> {
const packageManager = await detect({ programmatic: true, cwd: targetDir })

if (packageManager === "yarn@berry") return "yarn"
if (packageManager === "pnpm@6") return "pnpm"
if (packageManager === "bun") return "npm"
if (packageManager === "bun") return "bun"

return packageManager ?? "npm"
}
Binary file added packages/cli/test/fixtures/project-bun/bun.lockb
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/cli/test/fixtures/project-bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "test-cli-project-bun",
"version": "1.0.0",
"main": "index.js",
"author": "shadcn",
"license": "MIT"
}
4 changes: 4 additions & 0 deletions packages/cli/test/utils/get-package-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ test("get package manager", async () => {
await getPackageManager(path.resolve(__dirname, "../fixtures/project-pnpm"))
).toBe("pnpm")

expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/project-bun"))
).toBe("bun")

expect(
await getPackageManager(path.resolve(__dirname, "../fixtures/next"))
).toBe("pnpm")
Expand Down

0 comments on commit c337753

Please sign in to comment.