Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da
2026-04-16
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -313,6 +313,33 @@ describe("bundled plugin metadata", () => {
|
313 | 313 | ).toBe(path.join(pluginRoot, "index.ts")); |
314 | 314 | }); |
315 | 315 | |
| 316 | +it("prefers direct scan-dir overrides over nested dist artifacts within the same override root", () => { |
| 317 | +const pluginsDir = createGeneratedPluginTempRoot("openclaw-bundled-plugin-direct-priority-"); |
| 318 | +const pluginRoot = path.join(pluginsDir, "alpha"); |
| 319 | +const nestedDistPluginRoot = path.join(pluginsDir, "dist", "extensions", "alpha"); |
| 320 | + |
| 321 | +fs.mkdirSync(pluginRoot, { recursive: true }); |
| 322 | +fs.mkdirSync(nestedDistPluginRoot, { recursive: true }); |
| 323 | +fs.writeFileSync(path.join(pluginRoot, "index.js"), "export const source = true;\n", "utf8"); |
| 324 | +fs.writeFileSync( |
| 325 | +path.join(nestedDistPluginRoot, "index.js"), |
| 326 | +"export const built = true;\n", |
| 327 | +"utf8", |
| 328 | +); |
| 329 | + |
| 330 | +expect( |
| 331 | +resolveBundledPluginGeneratedPath( |
| 332 | +pluginsDir, |
| 333 | +{ |
| 334 | +source: "./index.ts", |
| 335 | +built: "index.js", |
| 336 | +}, |
| 337 | +"alpha", |
| 338 | +pluginsDir, |
| 339 | +), |
| 340 | +).toBe(path.join(pluginRoot, "index.js")); |
| 341 | +}); |
| 342 | + |
316 | 343 | it("resolves bundled repo entry paths from dist before workspace source", () => { |
317 | 344 | const tempRoot = createGeneratedPluginTempRoot("openclaw-bundled-plugin-repo-entry-"); |
318 | 345 | const pluginRoot = path.join(tempRoot, "extensions", "alpha"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -248,9 +248,9 @@ function listBundledPluginEntryBaseDirs(params: {
|
248 | 248 | scanDir?: string; |
249 | 249 | }): string[] { |
250 | 250 | const baseDirs = [ |
| 251 | + ...(params.scanDir ? [path.resolve(params.scanDir, params.pluginDirName ?? "")] : []), |
251 | 252 | path.resolve(params.rootDir, "dist", "extensions", params.pluginDirName ?? ""), |
252 | 253 | path.resolve(params.rootDir, "extensions", params.pluginDirName ?? ""), |
253 | | - ...(params.scanDir ? [path.resolve(params.scanDir, params.pluginDirName ?? "")] : []), |
254 | 254 | ]; |
255 | 255 | return baseDirs.filter((entry, index, all) => all.indexOf(entry) === index); |
256 | 256 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。