






















11// OpenClaw SDK tests cover package behavior.
2-import { spawn } from "node:child_process";
2+import { spawn, type SpawnOptionsWithoutStdio } from "node:child_process";
33import { createReadStream } from "node:fs";
44import fs from "node:fs/promises";
55import { createServer, type Server } from "node:http";
66import os from "node:os";
77import path from "node:path";
8+import { createPnpmRunnerSpawnSpec } from "../../../scripts/pnpm-runner.mjs";
89import { afterEach, describe, expect, it } from "vitest";
910import { createNodeEvalArgs } from "../../../src/test-utils/node-process.js";
1011@@ -36,21 +37,20 @@ type PackedPackage = {
3637function runCommand(
3738command: string,
3839args: string[],
39-options: { cwd: string; timeoutMs?: number },
40+options: { cwd: string; timeoutMs?: number } & Pick<
41+SpawnOptionsWithoutStdio,
42+"env" | "shell" | "windowsVerbatimArguments"
43+>,
4044): Promise<CommandResult> {
4145return new Promise((resolve, reject) => {
4246const stdout: string[] = [];
4347const stderr: string[] = [];
4448const child = spawn(command, args, {
4549cwd: options.cwd,
46-env: {
47- ...process.env,
48-CI: process.env.CI ?? "true",
49-npm_config_audit: "false",
50-npm_config_fund: "false",
51-PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN: "false",
52-},
50+env: options.env ?? createCommandEnv(),
51+shell: options.shell,
5352stdio: ["ignore", "pipe", "pipe"],
53+windowsVerbatimArguments: options.windowsVerbatimArguments,
5454});
5555const timer = setTimeout(() => {
5656child.kill("SIGKILL");
@@ -88,6 +88,35 @@ function runCommand(
8888});
8989}
909091+function createCommandEnv(): NodeJS.ProcessEnv {
92+return {
93+ ...process.env,
94+CI: process.env.CI ?? "true",
95+npm_config_audit: "false",
96+npm_config_fund: "false",
97+PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN: "false",
98+};
99+}
100+101+function runPnpmCommand(
102+args: string[],
103+options: { cwd: string; timeoutMs?: number },
104+): Promise<CommandResult> {
105+const spec = createPnpmRunnerSpawnSpec({
106+cwd: options.cwd,
107+env: createCommandEnv(),
108+pnpmArgs: args,
109+stdio: ["ignore", "pipe", "pipe"],
110+});
111+return runCommand(spec.command, spec.args, {
112+cwd: spec.options.cwd ?? options.cwd,
113+env: spec.options.env,
114+shell: spec.options.shell,
115+timeoutMs: options.timeoutMs,
116+windowsVerbatimArguments: spec.options.windowsVerbatimArguments,
117+});
118+}
119+91120function normalizeWorkspaceDependencies(
92121dependencies: Record<string, string> | undefined,
93122): Record<string, string> | undefined {
@@ -226,7 +255,7 @@ describe("OpenClaw SDK package e2e", () => {
226255tempDirs.push(tempDir);
227256228257for (const packageName of WORKSPACE_PACKAGE_NAMES) {
229-await runCommand("pnpm", ["--filter", packageName, "build"], {
258+await runPnpmCommand(["--filter", packageName, "build"], {
230259cwd: repoRoot,
231260timeoutMs: 180_000,
232261});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。