Skip to content

Commit 0e9d1f1

Browse files
authored
enhance(tool/fix-flaws): add progress bar (#9433)
1 parent 0312f1a commit 0e9d1f1

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Diff for: tool/cli.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { fdir, PathsOutput } from "fdir";
88
import frontmatter from "front-matter";
99
import caporal from "@caporal/core";
1010
import chalk from "chalk";
11+
import cliProgress from "cli-progress";
1112
import inquirer from "inquirer";
1213
import openEditor from "open-editor";
1314
import open from "open";
@@ -752,15 +753,28 @@ program
752753
const allDocs = await Document.findAll({
753754
locales: new Map([[locale.toLowerCase(), true]]),
754755
});
756+
const progressBar = new cliProgress.SingleBar(
757+
{},
758+
cliProgress.Presets.shades_grey
759+
);
760+
progressBar.start(allDocs.count, 0);
761+
755762
for (const document of allDocs.iterDocs()) {
756-
if (fileTypes.includes(document.isMarkdown ? "md" : "html")) {
757-
await buildDocument(document, {
758-
fixFlaws: true,
759-
fixFlawsTypes: new Set(fixFlawsTypes),
760-
fixFlawsVerbose: true,
761-
});
763+
try {
764+
if (fileTypes.includes(document.isMarkdown ? "md" : "html")) {
765+
await buildDocument(document, {
766+
fixFlaws: true,
767+
fixFlawsTypes: new Set(fixFlawsTypes),
768+
fixFlawsVerbose: true,
769+
});
770+
}
771+
} catch (e) {
772+
console.error(e);
762773
}
774+
progressBar.increment();
763775
}
776+
777+
progressBar.stop();
764778
})
765779
)
766780

0 commit comments

Comments
 (0)