mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-29 15:25:14 +00:00
Summary: - The PR extracts JSON-mode console-to-stderr routing into a shared CLI helper, wraps root and `nodes` lazy plugin registration, adds nodes registration coverage, and adds a changelog entry. - Reproducibility: yes. for source-level reproduction: the linked report shows `openclaw nodes list --json 2> ... ssing the existing JSON stderr guard. I did not run the live Helm/container repro in this read-only review. Automerge notes: - PR branch already contained follow-up commit before automerge: Route JSON-mode plugin registration logs to stderr Validation: - ClawSweeper review passed for headc9d0867db0. - Required merge gates passed before the squash merge. Prepared head SHA:c9d0867db0Review: https://github.com/openclaw/openclaw/pull/84741#issuecomment-4503741078 Co-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com> Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
30 lines
715 B
TypeScript
30 lines
715 B
TypeScript
import { loggingState } from "../logging/state.js";
|
|
|
|
export function hasJsonOutputFlag(argv: readonly string[]): boolean {
|
|
for (const arg of argv) {
|
|
if (arg === "--") {
|
|
return false;
|
|
}
|
|
if (arg === "--json" || arg.startsWith("--json=")) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export async function withConsoleLogsRoutedToStderrForJson<T>(
|
|
argv: readonly string[],
|
|
run: () => Promise<T>,
|
|
): Promise<T> {
|
|
if (!hasJsonOutputFlag(argv)) {
|
|
return run();
|
|
}
|
|
const previousForceStderr = loggingState.forceConsoleToStderr;
|
|
loggingState.forceConsoleToStderr = true;
|
|
try {
|
|
return await run();
|
|
} finally {
|
|
loggingState.forceConsoleToStderr = previousForceStderr;
|
|
}
|
|
}
|