fix: tolerate pnpm-backed runtime dependency installs

This commit is contained in:
Peter Steinberger
2026-04-21 06:57:45 +01:00
parent 05ba1335d9
commit 494cd78889
5 changed files with 94 additions and 53 deletions

View File

@@ -2,6 +2,8 @@ import fs from "node:fs/promises";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import {
createBundledRuntimeDependencyInstallArgs,
createBundledRuntimeDependencyInstallEnv,
createNestedNpmInstallEnv,
pruneInstalledPackageDist,
discoverBundledPluginRuntimeDeps,
@@ -47,14 +49,7 @@ async function writePluginPackage(
describe("bundled plugin postinstall", () => {
function createNpmInstallArgs(...packages: string[]) {
return [
"install",
"--omit=dev",
"--no-save",
"--package-lock=false",
"--legacy-peer-deps",
...packages,
];
return createBundledRuntimeDependencyInstallArgs(packages);
}
function createBareNpmRunner(packages: string[]) {
@@ -122,6 +117,25 @@ describe("bundled plugin postinstall", () => {
});
});
it("uses package-manager-neutral runtime install args with npm config env", () => {
expect(createBundledRuntimeDependencyInstallArgs(["acpx@0.4.1"])).toEqual([
"install",
"--ignore-scripts",
"acpx@0.4.1",
]);
expect(
createBundledRuntimeDependencyInstallEnv({
HOME: "/tmp/home",
npm_config_prefix: "/opt/homebrew",
}),
).toEqual({
HOME: "/tmp/home",
npm_config_legacy_peer_deps: "true",
npm_config_package_lock: "false",
npm_config_save: "false",
});
});
it("does not install bundled plugin deps outside of source checkouts by default", async () => {
const extensionsDir = await createExtensionsDir();
const packageRoot = path.dirname(path.dirname(extensionsDir));