From 0e9d1f1e1f158a7bc49dcdc1e9e9f521c71cb04f Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Thu, 28 Mar 2024 06:02:23 -0700 Subject: [PATCH] enhance(tool/fix-flaws): add progress bar (#9433) --- tool/cli.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/tool/cli.ts b/tool/cli.ts index 23e12f46bceb..4f70d2a3a9a6 100644 --- a/tool/cli.ts +++ b/tool/cli.ts @@ -8,6 +8,7 @@ import { fdir, PathsOutput } from "fdir"; import frontmatter from "front-matter"; import caporal from "@caporal/core"; import chalk from "chalk"; +import cliProgress from "cli-progress"; import inquirer from "inquirer"; import openEditor from "open-editor"; import open from "open"; @@ -752,15 +753,28 @@ program const allDocs = await Document.findAll({ locales: new Map([[locale.toLowerCase(), true]]), }); + const progressBar = new cliProgress.SingleBar( + {}, + cliProgress.Presets.shades_grey + ); + progressBar.start(allDocs.count, 0); + for (const document of allDocs.iterDocs()) { - if (fileTypes.includes(document.isMarkdown ? "md" : "html")) { - await buildDocument(document, { - fixFlaws: true, - fixFlawsTypes: new Set(fixFlawsTypes), - fixFlawsVerbose: true, - }); + try { + if (fileTypes.includes(document.isMarkdown ? "md" : "html")) { + await buildDocument(document, { + fixFlaws: true, + fixFlawsTypes: new Set(fixFlawsTypes), + fixFlawsVerbose: true, + }); + } + } catch (e) { + console.error(e); } + progressBar.increment(); } + + progressBar.stop(); }) )