mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 02:32:44 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -31,9 +31,13 @@ import {
|
||||
import { addGatewayRunCommand } from "./run.js";
|
||||
|
||||
function styleHealthChannelLine(line: string, rich: boolean): string {
|
||||
if (!rich) return line;
|
||||
if (!rich) {
|
||||
return line;
|
||||
}
|
||||
const colon = line.indexOf(":");
|
||||
if (colon === -1) return line;
|
||||
if (colon === -1) {
|
||||
return line;
|
||||
}
|
||||
|
||||
const label = line.slice(0, colon + 1);
|
||||
const detail = line.slice(colon + 1).trimStart();
|
||||
@@ -42,13 +46,27 @@ function styleHealthChannelLine(line: string, rich: boolean): string {
|
||||
const applyPrefix = (prefix: string, color: (value: string) => string) =>
|
||||
`${label} ${color(detail.slice(0, prefix.length))}${detail.slice(prefix.length)}`;
|
||||
|
||||
if (normalized.startsWith("failed")) return applyPrefix("failed", theme.error);
|
||||
if (normalized.startsWith("ok")) return applyPrefix("ok", theme.success);
|
||||
if (normalized.startsWith("linked")) return applyPrefix("linked", theme.success);
|
||||
if (normalized.startsWith("configured")) return applyPrefix("configured", theme.success);
|
||||
if (normalized.startsWith("not linked")) return applyPrefix("not linked", theme.warn);
|
||||
if (normalized.startsWith("not configured")) return applyPrefix("not configured", theme.muted);
|
||||
if (normalized.startsWith("unknown")) return applyPrefix("unknown", theme.warn);
|
||||
if (normalized.startsWith("failed")) {
|
||||
return applyPrefix("failed", theme.error);
|
||||
}
|
||||
if (normalized.startsWith("ok")) {
|
||||
return applyPrefix("ok", theme.success);
|
||||
}
|
||||
if (normalized.startsWith("linked")) {
|
||||
return applyPrefix("linked", theme.success);
|
||||
}
|
||||
if (normalized.startsWith("configured")) {
|
||||
return applyPrefix("configured", theme.success);
|
||||
}
|
||||
if (normalized.startsWith("not linked")) {
|
||||
return applyPrefix("not linked", theme.warn);
|
||||
}
|
||||
if (normalized.startsWith("not configured")) {
|
||||
return applyPrefix("not configured", theme.muted);
|
||||
}
|
||||
if (normalized.startsWith("unknown")) {
|
||||
return applyPrefix("unknown", theme.warn);
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
@@ -62,10 +80,14 @@ function runGatewayCommand(action: () => Promise<void>, label?: string) {
|
||||
}
|
||||
|
||||
function parseDaysOption(raw: unknown, fallback = 30): number {
|
||||
if (typeof raw === "number" && Number.isFinite(raw)) return Math.max(1, Math.floor(raw));
|
||||
if (typeof raw === "number" && Number.isFinite(raw)) {
|
||||
return Math.max(1, Math.floor(raw));
|
||||
}
|
||||
if (typeof raw === "string" && raw.trim() !== "") {
|
||||
const parsed = Number(raw);
|
||||
if (Number.isFinite(parsed)) return Math.max(1, Math.floor(parsed));
|
||||
if (Number.isFinite(parsed)) {
|
||||
return Math.max(1, Math.floor(parsed));
|
||||
}
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
@@ -324,7 +346,9 @@ export function registerGatewayCli(program: Command) {
|
||||
`Found ${deduped.length} gateway(s) · domains: ${domains.join(", ")}`,
|
||||
),
|
||||
);
|
||||
if (deduped.length === 0) return;
|
||||
if (deduped.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const beacon of deduped) {
|
||||
for (const line of renderBeaconLines(beacon, rich)) {
|
||||
|
||||
Reference in New Issue
Block a user