From 09047244b3ebdf69fb5d1027fdb989b31b031d58 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 07:27:19 +0530 Subject: [PATCH 1/2] fix: limit progress bar length to 40 when no columns provided --- lib/node/nodeConsole.js | 6 ++---- test/ProgressPlugin.test.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node/nodeConsole.js b/lib/node/nodeConsole.js index 83b068b9aa7..dbb74d807b9 100644 --- a/lib/node/nodeConsole.js +++ b/lib/node/nodeConsole.js @@ -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 = process.stderr.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}`); diff --git a/test/ProgressPlugin.test.js b/test/ProgressPlugin.test.js index 9f1a32c4d7e..00fc7594296 100644 --- a/test/ProgressPlugin.test.js +++ b/test/ProgressPlugin.test.js @@ -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); }); }); From 94f880407a9645b18a8d65a15e8fd6a5f07fc165 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 12 Mar 2023 15:55:43 +0530 Subject: [PATCH 2/2] test: update ProgressPlugin test cases --- lib/node/nodeConsole.js | 2 +- test/ProgressPlugin.test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node/nodeConsole.js b/lib/node/nodeConsole.js index dbb74d807b9..3365f6bda20 100644 --- a/lib/node/nodeConsole.js +++ b/lib/node/nodeConsole.js @@ -38,7 +38,7 @@ module.exports = ({ colors, appendOnly, stream }) => { const writeStatusMessage = () => { if (!currentStatusMessage) return; - const l = process.stderr.columns || 40; + const l = stream.columns || 40; const args = truncateArgs(currentStatusMessage, l - 1); const str = args.join(" "); const coloredStr = `\u001b[1m${str}\u001b[39m\u001b[22m`; diff --git a/test/ProgressPlugin.test.js b/test/ProgressPlugin.test.js index 00fc7594296..f8d2aecac0a 100644 --- a/test/ProgressPlugin.test.js +++ b/test/ProgressPlugin.test.js @@ -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(