getState
This commit is contained in:
parent
021700e785
commit
0de8b07e29
18
src/shell.ts
18
src/shell.ts
|
|
@ -28,13 +28,7 @@ export async function runCommand(session: string, id: string, input: string): Pr
|
||||||
|
|
||||||
let status: "ok" | "error" = "ok"
|
let status: "ok" | "error" = "ok"
|
||||||
let output: CommandOutput = ""
|
let output: CommandOutput = ""
|
||||||
|
const state = getState(session, id)
|
||||||
let state = sessions.get(session)
|
|
||||||
if (!state) {
|
|
||||||
state = { session, id, project: "" }
|
|
||||||
sessions.set(session, state)
|
|
||||||
}
|
|
||||||
state.id = id
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
[status, output] = await Thread.run(state, async () => await exec(cmd, args))
|
[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 {
|
function commandPath(cmd: string): string | undefined {
|
||||||
const sysPath = join(NOSE_SYS_BIN, cmd + ".ts")
|
const sysPath = join(NOSE_SYS_BIN, cmd + ".ts")
|
||||||
const usrPath = join(NOSE_BIN, cmd + ".ts")
|
const usrPath = join(NOSE_BIN, cmd + ".ts")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user