@@ -5,6 +5,7 @@ import os from "node:os";
|
5 | 5 | import path from "node:path"; |
6 | 6 | import { afterEach, describe, expect, it, vi } from "vitest"; |
7 | 7 | import { withTempDir } from "../test-helpers/temp-dir.js"; |
| 8 | +import { captureEnv, setTestEnvValue } from "../test-utils/env.js"; |
8 | 9 | import { |
9 | 10 | downloadClawHubPackageArchive, |
10 | 11 | downloadClawHubSkillArchive, |
@@ -61,7 +62,7 @@ function createStalledBodyResponse(params: { headers: HeadersInit; firstChunk: U
|
61 | 62 | } |
62 | 63 | |
63 | 64 | describe("clawhub helpers", () => { |
64 | | -const originalHome = process.env.HOME; |
| 65 | +const originalEnv = captureEnv(["HOME", "XDG_CONFIG_HOME"]); |
65 | 66 | |
66 | 67 | afterEach(() => { |
67 | 68 | delete process.env.OPENCLAW_CLAWHUB_URL; |
@@ -71,12 +72,7 @@ describe("clawhub helpers", () => {
|
71 | 72 | delete process.env.OPENCLAW_CLAWHUB_CONFIG_PATH; |
72 | 73 | delete process.env.CLAWHUB_CONFIG_PATH; |
73 | 74 | delete process.env.CLAWDHUB_CONFIG_PATH; |
74 | | -delete process.env.XDG_CONFIG_HOME; |
75 | | -if (originalHome == null) { |
76 | | -delete process.env.HOME; |
77 | | -} else { |
78 | | -process.env.HOME = originalHome; |
79 | | -} |
| 75 | +originalEnv.restore(); |
80 | 76 | }); |
81 | 77 | |
82 | 78 | it("parses explicit ClawHub package specs", () => { |
@@ -264,7 +260,7 @@ describe("clawhub helpers", () => {
|
264 | 260 | await withTempDir({ prefix: "openclaw-clawhub-xdg-" }, async (xdgRoot) => { |
265 | 261 | const configPath = path.join(xdgRoot, "clawhub", "config.json"); |
266 | 262 | const homedirSpy = vi.spyOn(os, "homedir").mockReturnValue(fakeHome); |
267 | | -process.env.XDG_CONFIG_HOME = xdgRoot; |
| 263 | +setTestEnvValue("XDG_CONFIG_HOME", xdgRoot); |
268 | 264 | try { |
269 | 265 | await fs.mkdir(path.dirname(configPath), { recursive: true }); |
270 | 266 | await fs.writeFile(configPath, JSON.stringify({ token: "xdg-token-123" }), "utf8"); |
|