Skip to content

Commit 86c6907

Browse files
author
claw
committed
fix: address lint errors - add braces and avoid spread-in-map
1 parent 36f7b7e commit 86c6907

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/cli/cron-cli/shared.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export function printCronJson(value: unknown) {
3535
* This mirrors the human-readable status shown by `cron list` / `cron show`.
3636
*/
3737
export function enrichCronJsonWithStatus(value: unknown): unknown {
38-
if (!value || typeof value !== "object") return value;
38+
if (!value || typeof value !== "object") {
39+
return value;
40+
}
3941
const obj = value as Record<string, unknown>;
4042

4143
// Single job object (has 'state' and 'enabled')
@@ -45,22 +47,24 @@ export function enrichCronJsonWithStatus(value: unknown): unknown {
4547

4648
// List response (has 'jobs' array)
4749
if ("jobs" in obj && Array.isArray(obj.jobs)) {
48-
return {
49-
...obj,
50-
jobs: (obj.jobs as CronJob[]).map((job) => ({
51-
...job,
52-
status: computeStatus(job),
53-
})),
54-
};
50+
const enrichedJobs = (obj.jobs as CronJob[]).map((job) => {
51+
const status = computeStatus(job);
52+
return Object.assign({}, job, { status });
53+
});
54+
return { ...obj, jobs: enrichedJobs };
5555
}
5656

5757
return value;
5858
}
5959

6060
function computeStatus(job: CronJob): string {
61-
if (!job.enabled) return "disabled";
61+
if (!job.enabled) {
62+
return "disabled";
63+
}
6264
const state = job.state ?? {};
63-
if (state.runningAtMs) return "running";
65+
if (state.runningAtMs) {
66+
return "running";
67+
}
6468
return state.lastRunStatus ?? state.lastStatus ?? "idle";
6569
}
6670

0 commit comments

Comments
 (0)