Skip to content

Commit

Permalink
enhance(tool/fix-flaws): add progress bar (#9433)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Mar 28, 2024
1 parent 0312f1a commit 0e9d1f1
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions tool/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
})
)

Expand Down

0 comments on commit 0e9d1f1

Please sign in to comment.