feat: add requests progress bar

Signed-off-by: Dmytro Stanchiev <git@dmytros.dev>
This commit is contained in:
2025-09-18 17:12:10 -04:00
parent 49a32bf6b4
commit d42c74331e
3 changed files with 30 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { parseHTML } from "linkedom";
import unidecode from "unidecode";
import cliProgress from "cli-progress";
// const unidecode = require("unidecode");
@@ -348,6 +349,14 @@ export default async function fetchKijijiItems(
`Found ${listingLinks.length} listing links. Fetching details...`,
);
const progressBar = new cliProgress.SingleBar(
{},
cliProgress.Presets.shades_classic,
);
const totalProgress = listingLinks.length;
let currentProgress = 0;
progressBar.start(totalProgress, currentProgress);
const items: ListingDetails[] = [];
for (const link of listingLinks) {
try {
@@ -372,6 +381,9 @@ export default async function fetchKijijiItems(
`Failed to fetch ${link} - ${String((err as Error)?.message || err)}`,
);
}
} finally {
currentProgress++;
progressBar.update(currentProgress);
}
}