From 7db547a6f4b24cb8b08907739937385fc96847f5 Mon Sep 17 00:00:00 2001 From: Calvin Prewitt Date: Tue, 5 Nov 2024 13:51:54 -0600 Subject: [PATCH] added ability to set stdin --- packages/preview2-shim/lib/browser-async/cli.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/preview2-shim/lib/browser-async/cli.js b/packages/preview2-shim/lib/browser-async/cli.js index 0d21db821..cf7c47fd8 100644 --- a/packages/preview2-shim/lib/browser-async/cli.js +++ b/packages/preview2-shim/lib/browser-async/cli.js @@ -3,6 +3,7 @@ import { _setCwd as fsSetCwd } from './filesystem.js'; const textDecoder = new TextDecoder(); +let stdinStream, stdoutStream, stderrStream; let _env = [], _args = [], _cwd = "/"; export function _setEnv (envObj) { _env = Object.entries(envObj); @@ -10,10 +11,13 @@ export function _setEnv (envObj) { export function _setArgs (args) { _args = args; } - export function _setCwd (cwd) { fsSetCwd(_cwd = cwd); } +export function _setStdin (stream) { + stdinStream = stream; +} + export const environment = { getEnvironment () { @@ -44,7 +48,6 @@ export const exit = { } }; -let stdinStream; export const stdin = { InputStream, getStdin () { @@ -55,7 +58,6 @@ export const stdin = { } }; -let stdoutStream; export const stdout = { OutputStream, getStdout () { @@ -76,7 +78,6 @@ export const stdout = { } }; -let stderrStream; export const stderr = { OutputStream, getStderr () {