mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:21:23 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
28
src/infra/runtime-status.ts
Normal file
28
src/infra/runtime-status.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
type RuntimeStatusFormatInput = {
|
||||
status?: string;
|
||||
pid?: number;
|
||||
state?: string;
|
||||
details?: string[];
|
||||
};
|
||||
|
||||
export function formatRuntimeStatusWithDetails({
|
||||
status,
|
||||
pid,
|
||||
state,
|
||||
details = [],
|
||||
}: RuntimeStatusFormatInput): string {
|
||||
const runtimeStatus = status ?? "unknown";
|
||||
const fullDetails: string[] = [];
|
||||
if (pid) {
|
||||
fullDetails.push(`pid ${pid}`);
|
||||
}
|
||||
if (state && state.toLowerCase() !== runtimeStatus) {
|
||||
fullDetails.push(`state ${state}`);
|
||||
}
|
||||
for (const detail of details) {
|
||||
if (detail) {
|
||||
fullDetails.push(detail);
|
||||
}
|
||||
}
|
||||
return fullDetails.length > 0 ? `${runtimeStatus} (${fullDetails.join(", ")})` : runtimeStatus;
|
||||
}
|
||||
Reference in New Issue
Block a user