Handle linking to non-pnpm deps in pnpm-link (#32720)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2026-03-05 21:41:31 +00:00
committed by GitHub
parent cd3b9efe50
commit b2674e6fa4
+4 -2
View File
@@ -13,7 +13,7 @@ Please see LICENSE files in the repository root for full details.
// replacing them with a symlink/directory junction. // replacing them with a symlink/directory junction.
// This tool is a helpful substitute to `pnpm link` as that modifies the package.json & pnpm-lock.yaml files. // This tool is a helpful substitute to `pnpm link` as that modifies the package.json & pnpm-lock.yaml files.
import fs from "node:fs/promises"; import * as fs from "node:fs/promises";
import { join, dirname } from "node:path"; import { join, dirname } from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { execSync } from "node:child_process"; import { execSync } from "node:child_process";
@@ -48,8 +48,10 @@ try {
console.log(`Linking ${dependency} to ${path}`); console.log(`Linking ${dependency} to ${path}`);
await fs.symlink(path, dependencyPath); await fs.symlink(path, dependencyPath);
const pkgJson = await fs.readFile(join(path, "package.json"), "utf-8");
const pkgManager = JSON.parse(pkgJson)["packageManager"]?.split("@").at(0) ?? "yarn";
// pnpm install may have wiped out the `node_modules` dir so we have to restore it // pnpm install may have wiped out the `node_modules` dir so we have to restore it
execSync("pnpm i --ignore-scripts --frozen-lockfile", { execSync(`${pkgManager} install --ignore-scripts --frozen-lockfile`, {
cwd: dependencyPath, cwd: dependencyPath,
}); });
} catch (e) { } catch (e) {