mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
c70aee247e
* refactor(scripts): migrate JavaScript tools to TypeScript * fix(ci): keep changed-scope preflight zero-install * fix(ci): preserve zero-install script owners * fix(ci): complete script migration follow-through * fix(release): keep stable closeout zero-install * fix(scripts): preserve standalone execution boundaries * fix(scripts): repair standalone loader boundaries * fix(scripts): normalize gateway observation ids * fix(scripts): keep Docker packager standalone * test(scripts): preserve rebase cleanup helpers * test(sessions): use tracked temp directory
30 lines
962 B
TypeScript
30 lines
962 B
TypeScript
// Formats compact timing summaries for changed-check command groups.
|
|
type CommandTiming = { durationMs: number; name: string; status: number };
|
|
|
|
/** Format a duration in milliseconds for command summaries. */
|
|
export function formatMs(durationMs: number) {
|
|
if (durationMs < 1000) {
|
|
return `${Math.round(durationMs)}ms`;
|
|
}
|
|
return `${(durationMs / 1000).toFixed(2)}s`;
|
|
}
|
|
|
|
/** Print a stderr timing summary for a list of named command results. */
|
|
export function printTimingSummary(
|
|
label: string,
|
|
timings: readonly CommandTiming[],
|
|
options: { skipWhenAllOk?: boolean } = {},
|
|
) {
|
|
if (options.skipWhenAllOk && timings.every((timing) => timing.status === 0)) {
|
|
return;
|
|
}
|
|
|
|
console.error(`\n[${label}] summary`);
|
|
for (const timing of timings) {
|
|
const status = timing.status === 0 ? "ok" : `failed:${timing.status}`;
|
|
console.error(
|
|
`${formatMs(timing.durationMs).padStart(8)} ${status.padEnd(9)} ${timing.name}`,
|
|
);
|
|
}
|
|
}
|