From 9d45cf9296b99e98cdf0fae7cedeada56c101560 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 1 Mar 2024 11:28:34 -0500 Subject: [PATCH] Use Node stdin API for Bun to allow basic functionality to work again --- src/bun/terminal_io.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bun/terminal_io.ts b/src/bun/terminal_io.ts index 18dfbe8..b7971af 100644 --- a/src/bun/terminal_io.ts +++ b/src/bun/terminal_io.ts @@ -7,6 +7,8 @@ import { defaultTerminalSize } from '../common/config.ts'; import { readKey } from '../common/fns.ts'; import { ITerminal, ITerminalSize } from '../common/types.ts'; +const encoder = new TextEncoder(); + async function _getTerminalSizeFromAnsi(): Promise { // Tell the cursor to move to Row 999 and Column 999 // Since this command specifically doesn't go off the screen @@ -46,8 +48,13 @@ const BunTerminalIO: ITerminal = { // to have consistent argument lists argv: (Bun.argv.length > 2) ? Bun.argv.slice(2) : [], inputLoop: async function* inputLoop() { - for await (const chunk of Bun.stdin.stream()) { - yield chunk; + // for await (const chunk of Bun.stdin.stream()) { + // yield chunk; + // } + // + // return null; + for await (const chunk of process.stdin) { + yield encoder.encode(chunk); } return null; @@ -73,7 +80,7 @@ const BunTerminalIO: ITerminal = { return chunk.value ?? null; }, writeStdout: async function write(s: string): Promise { - const buffer = new TextEncoder().encode(s); + const buffer = encoder.encode(s); await Bun.write(Bun.stdout, buffer); },