


























@@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
6677const tempDirs: string[] = [];
88const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
9+const originalTrustBundledPluginsDir = process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
9101011function createTempDir(): string {
1112const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-public-surface-loader-"));
@@ -27,6 +28,11 @@ afterEach(() => {
2728} else {
2829process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;
2930}
31+if (originalTrustBundledPluginsDir === undefined) {
32+delete process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
33+} else {
34+process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = originalTrustBundledPluginsDir;
35+}
3036});
31373238describe("bundled plugin public surface loader", () => {
@@ -128,7 +134,9 @@ describe("bundled plugin public surface loader", () => {
128134>(import.meta.url, "./public-surface-loader.js?scope=bundled-native-public-artifacts");
129135const tempRoot = createTempDir();
130136const bundledPluginsDir = path.join(tempRoot, "dist");
137+fs.mkdirSync(bundledPluginsDir, { recursive: true });
131138process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir;
139+process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = "1";
132140133141const firstPath = path.join(bundledPluginsDir, "demo-a", "api.js");
134142const secondPath = path.join(bundledPluginsDir, "demo-b", "api.js");
@@ -162,12 +170,14 @@ describe("bundled plugin public surface loader", () => {
162170}));
163171vi.resetModules();
164172165-const publicSurfaceLoader = await importFreshModule<
166-typeof import("./public-surface-loader.js")
167->(import.meta.url, "./public-surface-loader.js?scope=missing-location-retry");
168173const tempRoot = createTempDir();
169174const bundledPluginsDir = path.join(tempRoot, "dist");
175+fs.mkdirSync(bundledPluginsDir, { recursive: true });
170176process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir;
177+process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = "1";
178+const publicSurfaceLoader = await importFreshModule<
179+typeof import("./public-surface-loader.js")
180+>(import.meta.url, "./public-surface-loader.js?scope=missing-location-retry");
171181172182expect(
173183publicSurfaceLoader.resolveBundledPluginPublicArtifactPath({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。