From dd87a5e17f0b2481ca1ac2bd2b661c5caaf1549f Mon Sep 17 00:00:00 2001 From: James Prevett Date: Sun, 13 Oct 2024 00:19:27 -0500 Subject: [PATCH] Fix prompt --- src/shell.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/shell.ts b/src/shell.ts index 4bcc1bc..24bb5c2 100644 --- a/src/shell.ts +++ b/src/shell.ts @@ -108,16 +108,18 @@ function handleData($: ShellContext, data: string) { /** * Creates a new shell using the provided options */ -export function createShell({ terminal, prompt = '', onLine = () => {} }: ShellOptions): ShellContext { +export function createShell(options: ShellOptions): ShellContext { const context: ShellContext = { - terminal, - prompt, - onLine, + terminal: options.terminal, + get prompt() { + return options.prompt ?? ''; + }, + onLine: options.onLine ?? (() => {}), input: '', index: -1, currentInput: '', inputs: [], }; - terminal.onData(data => handleData(context, data)); + options.terminal.onData(data => handleData(context, data)); return context; }