mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 20:20:21 +00:00
refactor(core): dedupe infra, media, pairing, and plugin helpers
This commit is contained in:
@@ -26,6 +26,15 @@ async function withStateDir<T>(stateDir: string, fn: () => Promise<T>) {
|
||||
);
|
||||
}
|
||||
|
||||
async function discoverWithStateDir(
|
||||
stateDir: string,
|
||||
params: Parameters<typeof discoverOpenClawPlugins>[0],
|
||||
) {
|
||||
return await withStateDir(stateDir, async () => {
|
||||
return discoverOpenClawPlugins(params);
|
||||
});
|
||||
}
|
||||
|
||||
function writePluginPackageManifest(params: {
|
||||
packageDir: string;
|
||||
packageName: string;
|
||||
@@ -197,9 +206,7 @@ describe("discoverOpenClawPlugins", () => {
|
||||
});
|
||||
fs.writeFileSync(outside, "export default function () {}", "utf-8");
|
||||
|
||||
const result = await withStateDir(stateDir, async () => {
|
||||
return discoverOpenClawPlugins({});
|
||||
});
|
||||
const result = await discoverWithStateDir(stateDir, {});
|
||||
|
||||
expect(result.candidates).toHaveLength(0);
|
||||
expectEscapesPackageDiagnostic(result.diagnostics);
|
||||
@@ -225,9 +232,7 @@ describe("discoverOpenClawPlugins", () => {
|
||||
extensions: ["./linked/escape.ts"],
|
||||
});
|
||||
|
||||
const { candidates, diagnostics } = await withStateDir(stateDir, async () => {
|
||||
return discoverOpenClawPlugins({});
|
||||
});
|
||||
const { candidates, diagnostics } = await discoverWithStateDir(stateDir, {});
|
||||
|
||||
expect(candidates.some((candidate) => candidate.idHint === "pack")).toBe(false);
|
||||
expectEscapesPackageDiagnostic(diagnostics);
|
||||
|
||||
Reference in New Issue
Block a user