mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 18:12:52 +00:00
refactor(plugins): extract alias candidate resolution
This commit is contained in:
@@ -1351,6 +1351,20 @@ describe("loadOpenClawPlugins", () => {
|
||||
expect(resolved).toBe(distFile);
|
||||
});
|
||||
|
||||
it("prefers dist candidates first for production src runtime", () => {
|
||||
const { root, srcFile, distFile } = createPluginSdkAliasFixture();
|
||||
|
||||
const candidates = withEnv({ NODE_ENV: "production", VITEST: undefined }, () =>
|
||||
__testing.listPluginSdkAliasCandidates({
|
||||
srcFile: "index.ts",
|
||||
distFile: "index.js",
|
||||
modulePath: path.join(root, "src", "plugins", "loader.ts"),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(candidates.indexOf(distFile)).toBeLessThan(candidates.indexOf(srcFile));
|
||||
});
|
||||
|
||||
it("prefers src plugin-sdk alias when loader runs from src in non-production", () => {
|
||||
const { root, srcFile } = createPluginSdkAliasFixture();
|
||||
|
||||
@@ -1364,6 +1378,20 @@ describe("loadOpenClawPlugins", () => {
|
||||
expect(resolved).toBe(srcFile);
|
||||
});
|
||||
|
||||
it("prefers src candidates first for non-production src runtime", () => {
|
||||
const { root, srcFile, distFile } = createPluginSdkAliasFixture();
|
||||
|
||||
const candidates = withEnv({ NODE_ENV: undefined }, () =>
|
||||
__testing.listPluginSdkAliasCandidates({
|
||||
srcFile: "index.ts",
|
||||
distFile: "index.js",
|
||||
modulePath: path.join(root, "src", "plugins", "loader.ts"),
|
||||
}),
|
||||
);
|
||||
|
||||
expect(candidates.indexOf(srcFile)).toBeLessThan(candidates.indexOf(distFile));
|
||||
});
|
||||
|
||||
it("falls back to src plugin-sdk alias when dist is missing in production", () => {
|
||||
const { root, srcFile, distFile } = createPluginSdkAliasFixture();
|
||||
fs.rmSync(distFile);
|
||||
|
||||
Reference in New Issue
Block a user