Skip to content

Commit 6a3f990

Browse files
committed
fix: isolate plugin index loader env
1 parent 81abc2b commit 6a3f990

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

test/scripts/plugin-index-sqlite.test.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,15 @@ import path from "node:path";
55
import { DatabaseSync } from "node:sqlite";
66
import { pathToFileURL } from "node:url";
77
import { describe, expect, it } from "vitest";
8+
import { withEnvAsync } from "../../src/test-utils/env.js";
89

910
const MODULE_URL = pathToFileURL(path.resolve("scripts/e2e/lib/plugin-index-sqlite.mjs")).href;
1011
let importCounter = 0;
1112

1213
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 () => {
1615
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+
});
2617
}
2718

2819
function writeLegacyIndex(root: string, text: string) {

0 commit comments

Comments
 (0)