fix: isolate plugin index loader env · openclaw/openclaw@6a3f990
shakkernerd
·
2026-06-21
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,24 +5,15 @@ import path from "node:path";
|
5 | 5 | import { DatabaseSync } from "node:sqlite"; |
6 | 6 | import { pathToFileURL } from "node:url"; |
7 | 7 | import { describe, expect, it } from "vitest"; |
| 8 | +import { withEnvAsync } from "../../src/test-utils/env.js"; |
8 | 9 | |
9 | 10 | const MODULE_URL = pathToFileURL(path.resolve("scripts/e2e/lib/plugin-index-sqlite.mjs")).href; |
10 | 11 | let importCounter = 0; |
11 | 12 | |
12 | 13 | async function loadPluginIndex(env: Record<string, string> = {}) { |
13 | | -const previous = new Map(Object.keys(env).map((key) => [key, process.env[key]])); |
14 | | -Object.assign(process.env, env); |
15 | | -try { |
| 14 | +return await withEnvAsync(env, async () => { |
16 | 15 | return await import(`${MODULE_URL}?case=${importCounter++}`); |
17 | | -} finally { |
18 | | -for (const [key, value] of previous) { |
19 | | -if (value === undefined) { |
20 | | -delete process.env[key]; |
21 | | -} else { |
22 | | -process.env[key] = value; |
23 | | -} |
24 | | -} |
25 | | -} |
| 16 | +}); |
26 | 17 | } |
27 | 18 | |
28 | 19 | function writeLegacyIndex(root: string, text: string) { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。