Skip to content

Commit

Permalink
test(shadcn): add bun.lock
Browse files Browse the repository at this point in the history
  • Loading branch information
shadcn committed Feb 11, 2025
1 parent d5295e6 commit 18c53d3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/cli/src/utils/get-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { detect } from "@antfu/ni"

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

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

return packageManager ?? "npm"
}
4 changes: 2 additions & 2 deletions packages/shadcn/src/utils/get-package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export async function getPackageManager(
{ withFallback }: { withFallback?: boolean } = {
withFallback: false,
}
): Promise<"yarn" | "pnpm" | "bun" | "npm"> {
): Promise<"yarn" | "pnpm" | "bun" | "npm" | "deno"> {
const packageManager = await detect({ programmatic: true, cwd: targetDir })

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

if (packageManager === "deno") return "deno"
if (!withFallback) {
return packageManager ?? "npm"
}
Expand Down
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/shadcn/test/fixtures/project-bun-lock/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"
}
6 changes: 6 additions & 0 deletions packages/shadcn/test/utils/get-package-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ test("get package manager", async () => {
await getPackageManager(path.resolve(__dirname, "../fixtures/project-bun"))
).toBe("bun")

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

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

0 comments on commit 18c53d3

Please sign in to comment.