Skip to content

Commit

Permalink
fix(yarn): handle global for yarn 1.x only
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 3, 2024
1 parent 15aaee8 commit f5e4a39
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export async function addDependency(
resolvedOptions.packageManager.name === "yarn"
? [
...getWorkspaceArgs(resolvedOptions),
// Global is not supported in berry: yarnpkg/berry#821
resolvedOptions.global &&
resolvedOptions.packageManager.majorVersion === "1"
? "global"
: "",
"add",
resolvedOptions.dev ? "-D" : "",
...names,
Expand Down Expand Up @@ -108,11 +113,10 @@ export async function removeDependency(
const args = (
resolvedOptions.packageManager.name === "yarn"
? [
// prettier-ignore
resolvedOptions.global
? (resolvedOptions.packageManager.majorVersion === "1"
? "dlx"
: "global")
// Global is not supported in berry: yarnpkg/berry#821
resolvedOptions.global &&
resolvedOptions.packageManager.majorVersion === "1"
? "global"
: "",
...getWorkspaceArgs(resolvedOptions),
"remove",
Expand Down

0 comments on commit f5e4a39

Please sign in to comment.