

























@@ -65,8 +65,12 @@ describe("resolveBundledRuntimeDepsNpmRunner", () => {
6565{
6666PATH: "/usr/bin:/bin",
6767NPM_CONFIG_CACHE: "/Users/alice/.npm-uppercase",
68+NPM_CONFIG_GLOBAL: "true",
69+NPM_CONFIG_LOCATION: "global",
70+NPM_CONFIG_PREFIX: "/Users/alice",
6871npm_config_cache: "/Users/alice/.npm",
6972npm_config_global: "true",
73+npm_config_location: "global",
7074npm_config_prefix: "/opt/homebrew",
7175},
7276{ cacheDir: "/opt/openclaw/runtime-cache" },
@@ -170,6 +174,7 @@ describe("installBundledRuntimeDeps", () => {
170174});
171175172176it("uses the npm cmd shim on Windows", () => {
177+const installRoot = makeTempDir();
173178vi.spyOn(process, "platform", "get").mockReturnValue("win32");
174179vi.spyOn(fs, "existsSync").mockImplementation(
175180(candidate) => candidate === "C:\\node\\node_modules\\npm\\bin\\npm-cli.js",
@@ -184,7 +189,7 @@ describe("installBundledRuntimeDeps", () => {
184189});
185190186191installBundledRuntimeDeps({
187-installRoot: "C:\\openclaw",
192+ installRoot,
188193missingSpecs: ["acpx@0.5.3"],
189194env: {
190195npm_config_prefix: "C:\\prefix",
@@ -197,7 +202,7 @@ describe("installBundledRuntimeDeps", () => {
197202expect.any(String),
198203["C:\\node\\node_modules\\npm\\bin\\npm-cli.js", "install", "--ignore-scripts", "acpx@0.5.3"],
199204expect.objectContaining({
200-cwd: "C:\\openclaw",
205+cwd: installRoot,
201206env: expect.objectContaining({
202207npm_config_legacy_peer_deps: "true",
203208npm_config_package_lock: "false",
@@ -286,10 +291,20 @@ describe("installBundledRuntimeDeps", () => {
286291env: {
287292HOME: "/Users/alice",
288293NPM_CONFIG_CACHE: "/Users/alice/.npm-uppercase",
294+NPM_CONFIG_GLOBAL: "true",
295+NPM_CONFIG_LOCATION: "global",
296+NPM_CONFIG_PREFIX: "/Users/alice",
289297npm_config_cache: "/Users/alice/.npm",
298+npm_config_global: "true",
299+npm_config_location: "global",
300+npm_config_prefix: "/opt/homebrew",
290301},
291302});
292303304+expect(JSON.parse(fs.readFileSync(path.join(installRoot, "package.json"), "utf8"))).toEqual({
305+name: "openclaw-runtime-deps-install",
306+private: true,
307+});
293308expect(spawnSyncMock).toHaveBeenCalledWith(
294309expect.any(String),
295310expect.any(Array),
@@ -307,6 +322,12 @@ describe("installBundledRuntimeDeps", () => {
307322expect.objectContaining({
308323env: expect.not.objectContaining({
309324NPM_CONFIG_CACHE: expect.any(String),
325+NPM_CONFIG_GLOBAL: expect.any(String),
326+NPM_CONFIG_LOCATION: expect.any(String),
327+NPM_CONFIG_PREFIX: expect.any(String),
328+npm_config_global: expect.any(String),
329+npm_config_location: expect.any(String),
330+npm_config_prefix: expect.any(String),
310331}),
311332}),
312333);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。