Skip to content

Commit 592ca43

Browse files
authored
Merge pull request #444 from smoores-dev/fix-yarn-berry
Fix yarn berry commands
2 parents 4b7f532 + 42299bf commit 592ca43

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

apps/cli/src/services/commands/add.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ class Add extends Effect.Service<Add>()("Add", {
6666
const binaryRunner = yield* packageManager.getBinaryRunner(options.cwd)
6767

6868
const commandArgs = [
69-
binaryRunner[1],
70-
"--yes",
69+
...binaryRunner.slice(1),
7170
"shadcn@latest",
7271
"add",
7372
...shadcnOptions,

apps/cli/src/services/package-manager.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { Effect } from "effect"
22
import { detect } from "package-manager-detector"
33

4-
const PACKAGE_MANAGERS = ["npm", "bun", "pnpm", "yarn"] as const
4+
const PACKAGE_MANAGERS = ["npm", "bun", "pnpm", "yarn", "yarn@berry"] as const
55

6-
const BINARY_RUNNERS = { npm: ["npx"], bun: ["bunx", "--bun"], pnpm: ["pnpm", "dlx"], yarn: ["yarn"] } as const
6+
const BINARY_RUNNERS = {
7+
npm: ["npx", "--yes"],
8+
bun: ["bunx", "--bun", "--yes"],
9+
pnpm: ["pnpm", "dlx", "--yes"],
10+
yarn: ["yarn", "--yes"],
11+
"yarn@berry": ["yarn", "dlx"]
12+
} as const
713

814
const detectPackageManager = (cwd: string) =>
915
Effect.tryPromise({
@@ -22,7 +28,7 @@ const getPackageManager = (cwd: string) =>
2228
if (!pm) {
2329
return "npm"
2430
}
25-
const name = PACKAGE_MANAGERS.find((name) => pm.name.startsWith(name) || pm.agent.startsWith(name)) ?? "npm"
31+
const name = PACKAGE_MANAGERS.find((name) => pm.agent.startsWith(name) || pm.name.startsWith(name)) ?? "npm"
2632
return name
2733
})
2834
const getBinaryRunner = (cwd: string) =>

0 commit comments

Comments
 (0)