Skip to content

Commit 391d043

Browse files
authored
yarn plugins might be built-in (#147)
in yarn 4, all first-party plugins are installed by default. trying to install workspace-tools again fails. ref: yarnpkg/berry#4253
1 parent e754eb5 commit 391d043

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/yarn-plugins.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export async function getYarnPlugins({ cwd }: { cwd: CommonContext["cwd"] }) {
3434

3535
return stdout.split("\n").reduce((acc, line) => {
3636
try {
37-
const { name, builtin } = JSON.parse(line);
37+
const { name } = JSON.parse(line);
3838

39-
if (!builtin && name !== "@@core") {
39+
if (name !== "@@core") {
4040
return [...acc, name.replace("@yarnpkg/plugin-", "")];
4141
}
4242
} catch {

test/yarn-plugins.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ test.serial("getYarnPlugins", async (t) => {
2222

2323
const plugins = await getYarnPlugins(context);
2424

25-
t.deepEqual(plugins, ["interactive-tools", "typescript", "version"]);
25+
t.deepEqual(plugins, [
26+
"essentials",
27+
"compat",
28+
"pnp",
29+
"pnpm",
30+
"interactive-tools",
31+
"typescript",
32+
"version",
33+
]);
2634
});
2735

2836
test.serial("installYarnPluginIfNeeded when needed", async (t) => {
@@ -40,3 +48,11 @@ test.serial("installYarnPluginIfNeeded when not needed", async (t) => {
4048

4149
t.false(await installYarnPluginIfNeeded("version", context));
4250
});
51+
52+
test.serial("installYarnPluginIfNeeded when builtin", async (t) => {
53+
const context = createContext();
54+
55+
mockExeca({ stdout: '{"name":"@yarnpkg/plugin-version","builtin":true}' });
56+
57+
t.false(await installYarnPluginIfNeeded("version", context));
58+
});

0 commit comments

Comments
 (0)