From 0de8b07e29bda42b31b5d6cec04f91e4c109048f Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Sun, 21 Sep 2025 12:32:25 -0700 Subject: [PATCH] getState --- src/shell.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/shell.ts b/src/shell.ts index a63638b..0e7f9e9 100644 --- a/src/shell.ts +++ b/src/shell.ts @@ -28,13 +28,7 @@ export async function runCommand(session: string, id: string, input: string): Pr let status: "ok" | "error" = "ok" let output: CommandOutput = "" - - let state = sessions.get(session) - if (!state) { - state = { session, id, project: "" } - sessions.set(session, state) - } - state.id = id + const state = getState(session, id) try { [status, output] = await Thread.run(state, async () => await exec(cmd, args)) @@ -69,6 +63,16 @@ function processExecOutput(output: string | any): ["ok" | "error", CommandOutput } } +function getState(session: string, id: string): State { + let state = sessions.get(session) + if (!state) { + state = { session, project: "" } + sessions.set(session, state) + } + state.id = id + return state +} + function commandPath(cmd: string): string | undefined { const sysPath = join(NOSE_SYS_BIN, cmd + ".ts") const usrPath = join(NOSE_BIN, cmd + ".ts")