CLI: avoid plugin preload for health --json route (#31108)
* CLI routes: skip plugin preload for health --json * CLI routes tests: cover health --json plugin preload
This commit is contained in:
@@ -18,9 +18,12 @@ describe("program routes", () => {
|
||||
expect(route?.loadPlugins).toBe(true);
|
||||
});
|
||||
|
||||
it("matches health route and preloads plugins for channel diagnostics", () => {
|
||||
it("matches health route and preloads plugins only for text output", () => {
|
||||
const route = expectRoute(["health"]);
|
||||
expect(route?.loadPlugins).toBe(true);
|
||||
expect(typeof route?.loadPlugins).toBe("function");
|
||||
const shouldLoad = route?.loadPlugins as (argv: string[]) => boolean;
|
||||
expect(shouldLoad(["node", "openclaw", "health"])).toBe(true);
|
||||
expect(shouldLoad(["node", "openclaw", "health", "--json"])).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false when status timeout flag value is missing", async () => {
|
||||
|
||||
@@ -9,9 +9,9 @@ export type RouteSpec = {
|
||||
|
||||
const routeHealth: RouteSpec = {
|
||||
match: (path) => path[0] === "health",
|
||||
// Health output uses channel plugin metadata for account fallback/log details.
|
||||
// Keep routed behavior aligned with non-routed command execution.
|
||||
loadPlugins: true,
|
||||
// `health --json` only relays gateway RPC output and does not need local plugin metadata.
|
||||
// Keep plugin preload for text output where channel diagnostics/logSelfId are rendered.
|
||||
loadPlugins: (argv) => !hasFlag(argv, "--json"),
|
||||
run: async (argv) => {
|
||||
const json = hasFlag(argv, "--json");
|
||||
const verbose = getVerboseFlag(argv, { includeDebug: true });
|
||||
|
||||
Reference in New Issue
Block a user