

























@@ -6,6 +6,7 @@ import { createServer, type Server } from "node:http";
66import os from "node:os";
77import path from "node:path";
88import { afterEach, describe, expect, it, vi } from "vitest";
9+import { resolveNpmRunner } from "../../../scripts/npm-runner.mjs";
910import { createPnpmRunnerSpawnSpec } from "../../../scripts/pnpm-runner.mjs";
1011import { getWindowsSystem32ExePath } from "../../../src/infra/windows-install-roots.js";
1112import { createNodeEvalArgs } from "../../../src/test-utils/node-process.js";
@@ -162,6 +163,24 @@ function runPnpmCommand(
162163});
163164}
164165166+function runNpmCommand(
167+args: string[],
168+options: { cwd: string; timeoutMs?: number },
169+): Promise<CommandResult> {
170+const env = createCommandEnv();
171+const runner = resolveNpmRunner({
172+ env,
173+npmArgs: args,
174+});
175+return runCommand(runner.command, runner.args, {
176+cwd: options.cwd,
177+env: runner.env ?? env,
178+shell: runner.shell,
179+timeoutMs: options.timeoutMs,
180+windowsVerbatimArguments: runner.windowsVerbatimArguments,
181+});
182+}
183+165184function normalizeWorkspaceDependencies(
166185dependencies: Record<string, string> | undefined,
167186): Record<string, string> | undefined {
@@ -340,7 +359,7 @@ describe("OpenClaw SDK package e2e", () => {
340359}
341360for (const packageRoot of packageRoots) {
342361const stagingRoot = await createPackStagingRoot(packageRoot, tempDir);
343-await runCommand("npm", ["pack", "--ignore-scripts", "--pack-destination", tempDir], {
362+await runNpmCommand(["pack", "--ignore-scripts", "--pack-destination", tempDir], {
344363cwd: stagingRoot,
345364});
346365}
@@ -363,13 +382,9 @@ describe("OpenClaw SDK package e2e", () => {
363382);
364383await fs.writeFile(path.join(tempDir, ".npmrc"), `@openclaw:registry=${registry.registryUrl}`);
365384try {
366-await runCommand(
367-"npm",
368-["install", "--ignore-scripts", "--no-audit", "--no-fund", sdkTarball],
369-{
370-cwd: tempDir,
371-},
372-);
385+await runNpmCommand(["install", "--ignore-scripts", "--no-audit", "--no-fund", sdkTarball], {
386+cwd: tempDir,
387+});
373388} finally {
374389await registry.close();
375390}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。