Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit progress bar length to 40 when no columns provided #16810

Merged
merged 2 commits into from Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/node/nodeConsole.js
Expand Up @@ -38,10 +38,8 @@ module.exports = ({ colors, appendOnly, stream }) => {

const writeStatusMessage = () => {
if (!currentStatusMessage) return;
const l = stream.columns;
const args = l
? truncateArgs(currentStatusMessage, l - 1)
: currentStatusMessage;
const l = stream.columns || 40;
const args = truncateArgs(currentStatusMessage, l - 1);
const str = args.join(" ");
const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`;
stream.write(`\x1b[2K\r${coloredStr}`);
Expand Down
4 changes: 3 additions & 1 deletion test/ProgressPlugin.test.js
Expand Up @@ -218,7 +218,7 @@ describe("ProgressPlugin", function () {
const logs = getLogs(stderr.toString());

expect(logs.length).toBeGreaterThan(20);
expect(_.maxBy(logs, "length").length).toBeGreaterThan(50);
expect(_.maxBy(logs, "length").length).not.toBeGreaterThan(40);
});
});

Expand All @@ -242,6 +242,7 @@ describe("ProgressPlugin", function () {
activeModules: true
});

process.stderr.columns = 70;
return RunCompilerAsync(compiler).then(() => {
const logs = stderr.toString();

Expand All @@ -255,6 +256,7 @@ describe("ProgressPlugin", function () {
it("should get the custom handler text from the log", () => {
const compiler = createSimpleCompilerWithCustomHandler();

process.stderr.columns = 70;
return RunCompilerAsync(compiler).then(() => {
const logs = stderr.toString();
expect(logs).toEqual(
Expand Down