




























@@ -873,22 +873,43 @@ describe("install.sh", () => {
873873});
874874875875it("bounds installer npm prefix probes during finalization helpers", () => {
876-const result = runInstallShell(
876+const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-npm-probe-"));
877+const npm = join(tmp, "npm");
878+writeFileSync(
879+npm,
877880[
878-`source ${JSON.stringify(SCRIPT_PATH)}`,
879-"npm() {",
880-' if [[ "$1" == "prefix" && "$2" == "-g" ]]; then sleep 2; return 0; fi',
881-' if [[ "$1" == "config" && "$2" == "get" && "$3" == "prefix" ]]; then printf "/tmp/openclaw-npm\\n"; return 0; fi',
882-" return 1",
883-"}",
884-"npm_global_bin_dir",
881+"#!/usr/bin/env bash",
882+'if [[ "$1" == "prefix" && "$2" == "-g" ]]; then',
883+" sleep 3",
884+" exit 0",
885+"fi",
886+'if [[ "$1" == "config" && "$2" == "get" && "$3" == "prefix" ]]; then',
887+' printf "/tmp/openclaw-npm\\n"',
888+" exit 0",
889+"fi",
890+"exit 1",
891+"",
885892].join("\n"),
886-{ OPENCLAW_INSTALL_PROBE_TIMEOUT_SECONDS: "0.1" },
887893);
894+chmodSync(npm, 0o755);
888895889-expect(result.status).toBe(0);
890-expect(result.stdout.trim()).toBe("/tmp/openclaw-npm/bin");
891-expect(result.stderr).toContain("timed out during installer finalization probe: npm prefix -g");
896+try {
897+const result = runInstallShell(
898+[`source ${JSON.stringify(SCRIPT_PATH)}`, "npm_global_bin_dir"].join("\n"),
899+{
900+OPENCLAW_INSTALL_PROBE_TIMEOUT_SECONDS: "1",
901+PATH: `${tmp}:${process.env.PATH ?? ""}`,
902+},
903+);
904+905+expect(result.status).toBe(0);
906+expect(result.stdout.trim()).toBe("/tmp/openclaw-npm/bin");
907+expect(result.stderr).toContain(
908+"timed out during installer finalization probe: npm prefix -g",
909+);
910+} finally {
911+rmSync(tmp, { force: true, recursive: true });
912+}
892913});
893914894915it("bounds daemon status probes during finalization helpers", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。