mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
fix: isolate plugin index loader env
This commit is contained in:
@@ -5,24 +5,15 @@ import path from "node:path";
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { withEnvAsync } from "../../src/test-utils/env.js";
|
||||
|
||||
const MODULE_URL = pathToFileURL(path.resolve("scripts/e2e/lib/plugin-index-sqlite.mjs")).href;
|
||||
let importCounter = 0;
|
||||
|
||||
async function loadPluginIndex(env: Record<string, string> = {}) {
|
||||
const previous = new Map(Object.keys(env).map((key) => [key, process.env[key]]));
|
||||
Object.assign(process.env, env);
|
||||
try {
|
||||
return await withEnvAsync(env, async () => {
|
||||
return await import(`${MODULE_URL}?case=${importCounter++}`);
|
||||
} finally {
|
||||
for (const [key, value] of previous) {
|
||||
if (value === undefined) {
|
||||
delete process.env[key];
|
||||
} else {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function writeLegacyIndex(root: string, text: string) {
|
||||
|
||||
Reference in New Issue
Block a user