From 6477e1e8af1c0a9e78707a66c96e43f94d47067f Mon Sep 17 00:00:00 2001 From: Priyanshu Rav <77456300+priyanshurav@users.noreply.github.com> Date: Tue, 31 Mar 2026 22:49:44 +0530 Subject: [PATCH] fix: preserve script output lacking a final newline --- lib/utils/display.js | 5 ++--- test/lib/utils/display.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/utils/display.js b/lib/utils/display.js index 122a7f6e8c577..a09790171ec6f 100644 --- a/lib/utils/display.js +++ b/lib/utils/display.js @@ -543,9 +543,8 @@ class Progress { if (!this.#rendered) { return } - // Move to the start of the line and clear the rest of the line - this.#stream.cursorTo(0) - this.#stream.clearLine(1) + // Erase the last printed character + this.#stream.write('\b \b') this.#rendered = false } } diff --git a/test/lib/utils/display.js b/test/lib/utils/display.js index 89c4a85502849..39167dea1f073 100644 --- a/test/lib/utils/display.js +++ b/test/lib/utils/display.js @@ -96,7 +96,7 @@ t.test('can do progress', async (t) => { log.error('', 'after input') output.standard('after input') - t.strictSame([...new Set(outputErrors)].sort(), ['-', '/', '\\', '|']) + t.strictSame([...new Set(outputErrors)].sort(), ['\b \b', '-', '/', '\\', '|']) t.strictSame(logs, ['error before input', 'error during input', 'error after input']) t.strictSame(outputs, ['before input', 'during input', 'after input']) })