Skip to content

Commit

Permalink
improve output format
Browse files Browse the repository at this point in the history
  • Loading branch information
dtinth committed May 17, 2024
1 parent 773de25 commit d4afc1d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,23 @@ yargs(process.argv.slice(2))
status: statusMap.get(task.id),
};
});
const formatDuration = (status: Status) => {
if (!status.startedAt || !status.finishedAt) return "";
const startedAt = new Date(status.startedAt).getTime();
const finishedAt = new Date(status.finishedAt).getTime();
return ((finishedAt - startedAt) / 1000).toFixed(2) + "s";
};
console.table(
result.map((r) => ({
id: r.id,
status: r.status?.status,
workerId: r.status?.workerId,
duration: r.status ? formatDuration(r.status) : "",
}))
);
const out = JSON.stringify(result, null, 2);
if (args["out-file"]) {
fs.writeFileSync(args["out-file"], out);
} else {
console.log(out);
}
}
)
Expand Down

0 comments on commit d4afc1d

Please sign in to comment.