fix: keep root help plugin descriptor loading quiet · openclaw/openclaw@ef2ebee
steipete
·
2026-05-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -319,6 +319,23 @@ describe("registerPluginCliCommands", () => {
|
319 | 319 | }); |
320 | 320 | }); |
321 | 321 | |
| 322 | +it("keeps root-help descriptor load failures quiet", async () => { |
| 323 | +const stderrWrite = vi |
| 324 | +.spyOn(process.stderr, "write") |
| 325 | +.mockImplementation((() => true) as unknown as typeof process.stderr.write); |
| 326 | +mocks.loadOpenClawPluginCliRegistry.mockImplementationOnce((options: { logger?: unknown }) => { |
| 327 | +const logger = options.logger as { error?: (message: string) => void }; |
| 328 | +logger.error?.("[plugins] stale failed to load from /tmp/stale: boom"); |
| 329 | +throw new Error("boom"); |
| 330 | +}); |
| 331 | + |
| 332 | +await expect( |
| 333 | +getPluginCliCommandDescriptors({ plugins: { entries: { stale: {} } } } as OpenClawConfig), |
| 334 | +).resolves.toEqual([]); |
| 335 | + |
| 336 | +expect(stderrWrite).not.toHaveBeenCalled(); |
| 337 | +}); |
| 338 | + |
322 | 339 | it("keeps runtime CLI command registration on the full plugin loader for legacy channel plugins", async () => { |
323 | 340 | const { rawConfig, autoEnabledConfig } = createAutoEnabledCliFixture(); |
324 | 341 | mocks.applyPluginAutoEnable.mockReturnValue({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,7 +8,7 @@ import {
|
8 | 8 | type PluginCliLoaderOptions, |
9 | 9 | } from "./cli-registry-loader.js"; |
10 | 10 | import { registerPluginCliCommandGroups } from "./register-plugin-cli-command-groups.js"; |
11 | | -import type { OpenClawPluginCliCommandDescriptor } from "./types.js"; |
| 11 | +import type { OpenClawPluginCliCommandDescriptor, PluginLogger } from "./types.js"; |
12 | 12 | |
13 | 13 | type PluginCliRegistrationMode = "eager" | "lazy"; |
14 | 14 | |
@@ -35,6 +35,13 @@ const logger = createPluginCliLogger();
|
35 | 35 | const loaderOptionIds = new WeakMap<object, number>(); |
36 | 36 | let nextLoaderOptionId = 1; |
37 | 37 | |
| 38 | +const quietDescriptorLogger = { |
| 39 | +info: () => {}, |
| 40 | +warn: () => {}, |
| 41 | +error: () => {}, |
| 42 | +debug: () => {}, |
| 43 | +} satisfies PluginLogger; |
| 44 | + |
38 | 45 | function stableJsonKey(value: unknown): string { |
39 | 46 | if (value === undefined) { |
40 | 47 | return "undefined"; |
@@ -81,7 +88,7 @@ export async function getPluginCliCommandDescriptors(
|
81 | 88 | env?: NodeJS.ProcessEnv, |
82 | 89 | loaderOptions?: PluginCliLoaderOptions, |
83 | 90 | ): Promise<OpenClawPluginCliCommandDescriptor[]> { |
84 | | -return loadPluginCliDescriptors({ cfg, env, loaderOptions }); |
| 91 | +return loadPluginCliDescriptors({ cfg, env, loaderOptions, logger: quietDescriptorLogger }); |
85 | 92 | } |
86 | 93 | |
87 | 94 | export async function registerPluginCliCommands( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。