From 11fb3745dd548c6a8fa94c6a29e0ee89bac591aa Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Tue, 15 Mar 2022 10:30:25 -0700 Subject: [PATCH] [windows:ci] handle CLI output in a cross-compat way (#2801) * handle readline in a cross-compat way * Create modern-feet-lay.md --- .changeset/modern-feet-lay.md | 5 +++++ packages/astro/src/core/logger.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/modern-feet-lay.md diff --git a/.changeset/modern-feet-lay.md b/.changeset/modern-feet-lay.md new file mode 100644 index 000000000..f72cb4658 --- /dev/null +++ b/.changeset/modern-feet-lay.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Fix: Handle CLI output in a cross-compat way diff --git a/packages/astro/src/core/logger.ts b/packages/astro/src/core/logger.ts index 2f3620579..44b06834b 100644 --- a/packages/astro/src/core/logger.ts +++ b/packages/astro/src/core/logger.ts @@ -4,6 +4,7 @@ import { bold, cyan, dim, red, grey, underline, yellow, reset } from 'kleur/colo import { performance } from 'perf_hooks'; import { Writable } from 'stream'; import stringWidth from 'string-width'; +import * as readline from 'readline'; import debugPackage from 'debug'; import { format as utilFormat } from 'util'; @@ -69,9 +70,9 @@ export const defaultLogDestination = new Writable({ lines = Math.ceil(len / cols); } for (let i = 0; i < lines; i++) { - (dest as typeof process.stdout).clearLine(0); - (dest as typeof process.stdout).cursorTo(0); - (dest as typeof process.stdout).moveCursor(0, -1); + readline.clearLine(dest, 0); + readline.cursorTo(dest, 0); + readline.moveCursor(dest, 0, -1); } } message = `${message} ${yellow(`(x${lastMessageCount})`)}`;