Skip to content

Commit

Permalink
fix: not converting cli input to JS objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Aug 8, 2024
1 parent 495deaf commit 8e7c646
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,21 @@ class Cli {
`Interval to poll in seconds, default 180`,
)
.action(
async ({ data, interval }: { data: WatchData[]; interval: string }) => {
async ({ data, interval }: { data: string; interval: string }) => {
await tracer.startActiveSpan("watch", async (span) => {
if (data == null) this.err("Data is required, -d []");
if (data == null) this.err("Data is required, -d '[]'");
if (interval == null)
this.err("Interval is required, -i <seconds>");

const i = parseInt(interval);

if (isNaN(i)) this.err("Interval must be a number");

const dObj = JSON.parse(data);
this.logger.info({ jobData: dObj }, "Job data");
const all: Promise<void>[] = [];

for (const { date, from } of data) {
for (const { date, from } of dObj) {
const d = this.zincDate.from(date);
if (from !== "JToW" && from !== "WToJ")
this.err("From must be either 'JToW' or 'WToJ'");
Expand Down

0 comments on commit 8e7c646

Please sign in to comment.