From 2a74fb57a092459f12c5a8ec5696bf7810702636 Mon Sep 17 00:00:00 2001 From: Priyanshu Rav <77456300+priyanshurav@users.noreply.github.com> Date: Thu, 23 Oct 2025 23:24:29 +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 01ad55d4ce30c..67198d1a78365 100644 --- a/lib/utils/display.js +++ b/lib/utils/display.js @@ -515,9 +515,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 bc4e23485fa3e..e6dba25f61735 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']) })