Merge pull request #16810 from snitin315/fix/progress-length

fix: limit progress bar length to 40 when no columns provided
This commit is contained in:
Sean Larkin 2023-03-21 08:14:01 -07:00 committed by GitHub
commit eadbd7d5e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -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}`);

View File

@ -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);
});
});
@ -242,6 +242,7 @@ describe("ProgressPlugin", function () {
activeModules: true
});
process.stderr.columns = 70;
return RunCompilerAsync(compiler).then(() => {
const logs = stderr.toString();
@ -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(