fix(plugins): avoid managed npm prefix on Windows

Fixes #78514.
This commit is contained in:
Vincent Koc
2026-05-09 07:51:49 +08:00
committed by GitHub
parent becfeb48b4
commit 3ba2ce6694
8 changed files with 5 additions and 25 deletions

View File

@@ -69,8 +69,6 @@ function expectNpmInstallIntoRoot(params: { calls: unknown[][]; npmRoot: string
"--ignore-scripts",
"--no-audit",
"--no-fund",
"--prefix",
".",
]);
}
@@ -290,9 +288,7 @@ function mockNpmViewAndInstallMany(packages: MockNpmPackage[]) {
);
}
if (argv[0] === "npm" && argv[1] === "install") {
const prefixIndex = argv.indexOf("--prefix");
const prefixValue = prefixIndex >= 0 ? argv[prefixIndex + 1] : undefined;
const npmRoot = prefixValue === "." ? options?.cwd : prefixValue;
const npmRoot = options?.cwd;
if (!npmRoot) {
throw new Error(`unexpected npm install command: ${argv.join(" ")}`);
}
@@ -345,9 +341,7 @@ function mockNpmViewAndInstallMany(packages: MockNpmPackage[]) {
if (argv[0] === "npm" && argv[1] === "uninstall") {
const packageName = argv.at(-1);
if (packageName === "openclaw") {
const prefixIndex = argv.indexOf("--prefix");
const prefixValue = prefixIndex >= 0 ? argv[prefixIndex + 1] : undefined;
const npmRoot = prefixValue === "." ? options?.cwd : prefixValue;
const npmRoot = options?.cwd;
if (!npmRoot) {
throw new Error(`unexpected npm uninstall command: ${argv.join(" ")}`);
}

View File

@@ -328,8 +328,6 @@ async function rollbackManagedNpmPluginInstall(params: {
"--ignore-scripts",
"--no-audit",
"--no-fund",
"--prefix",
".",
params.packageName,
],
{
@@ -499,8 +497,6 @@ async function installPluginFromManagedNpmRoot(
noAudit: true,
noFund: true,
}),
"--prefix",
".",
],
{
cwd: npmRoot,

View File

@@ -992,8 +992,6 @@ describe("uninstallPlugin", () => {
"--ignore-scripts",
"--no-audit",
"--no-fund",
"--prefix",
".",
"@openclaw/kitchen-sink",
],
expect.objectContaining({
@@ -1128,8 +1126,6 @@ describe("uninstallPlugin", () => {
"--ignore-scripts",
"--no-audit",
"--no-fund",
"--prefix",
".",
"missing-plugin",
],
expect.objectContaining({

View File

@@ -611,8 +611,6 @@ export async function applyPluginUninstallDirectoryRemoval(
"--ignore-scripts",
"--no-audit",
"--no-fund",
"--prefix",
".",
removal.cleanup.packageName,
],
{