Skip to content

Commit 3add8fe

Browse files
committed
Improve console progress output when running in CI
Fixes #1732
1 parent 00e4119 commit 3add8fe

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

src/core/console.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,41 @@ export function progressBar(total: number, prefixMessage?: string): {
2525
update: (progress: number, status?: string) => void;
2626
complete: (finalMsg?: string | boolean) => void;
2727
} {
28+
const isCi = runningInCI();
29+
if (isCi && prefixMessage) {
30+
info(prefixMessage);
31+
}
32+
2833
// Core function to display the progressBar bar
2934
const updateProgress = (progress: number, status?: string) => {
30-
const progressBar = `${
31-
asciiProgressBar((progress / total) * 100, kProgressBarWidth)
32-
}`;
33-
const progressText = `\r${
34-
prefixMessage ? prefixMessage + " " : ""
35-
}${progressBar}${status ? " " + status : ""}`;
35+
if (!isCi) {
36+
const progressBar = `${
37+
asciiProgressBar((progress / total) * 100, kProgressBarWidth)
38+
}`;
39+
const progressText = `\r${
40+
prefixMessage ? prefixMessage + " " : ""
41+
}${progressBar}${status ? " " + status : ""}`;
3642

37-
clearLine();
38-
info(progressText, { newline: false });
43+
clearLine();
44+
info(progressText, { newline: false });
45+
}
3946
};
4047

4148
// Return control functions for progressBar
4249
return {
4350
update: updateProgress,
4451
complete: (finalMsg?: string | boolean) => {
4552
// Clear the line and display an optional final message
46-
clearLine();
53+
if (!isCi) {
54+
clearLine();
55+
}
56+
4757
if (typeof (finalMsg) === "string") {
48-
updateProgress(total, finalMsg);
58+
if (isCi) {
59+
info(finalMsg);
60+
} else {
61+
updateProgress(total, finalMsg);
62+
}
4963
} else {
5064
if (finalMsg !== false && prefixMessage) {
5165
completeMessage(prefixMessage);

0 commit comments

Comments
 (0)