diff options
Diffstat (limited to 'js/process.ts')
-rw-r--r-- | js/process.ts | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/js/process.ts b/js/process.ts index 2f60e5c4a..bf75b6b32 100644 --- a/js/process.ts +++ b/js/process.ts @@ -22,7 +22,6 @@ import { assert, unreachable } from "./util"; export type ProcessStdio = "inherit" | "piped" | "null"; // TODO Maybe extend VSCode's 'CommandOptions'? -// tslint:disable-next-line:max-line-length // See https://code.visualstudio.com/docs/editor/tasks-appendix#_schema-for-tasksjson export interface RunOptions { args: string[]; @@ -33,6 +32,27 @@ export interface RunOptions { stdin?: ProcessStdio; } +async function runStatus(rid: number): Promise<ProcessStatus> { + const builder = flatbuffers.createBuilder(); + msg.RunStatus.startRunStatus(builder); + msg.RunStatus.addRid(builder, rid); + const inner = msg.RunStatus.endRunStatus(builder); + + const baseRes = await dispatch.sendAsync(builder, msg.Any.RunStatus, inner); + assert(baseRes != null); + assert(msg.Any.RunStatusRes === baseRes!.innerType()); + const res = new msg.RunStatusRes(); + assert(baseRes!.inner(res) != null); + + if (res.gotSignal()) { + const signal = res.exitSignal(); + return { signal, success: false }; + } else { + const code = res.exitCode(); + return { code, success: code === 0 }; + } +} + export class Process { readonly rid: number; readonly pid: number; @@ -156,24 +176,3 @@ export function run(opt: RunOptions): Process { return new Process(res); } - -async function runStatus(rid: number): Promise<ProcessStatus> { - const builder = flatbuffers.createBuilder(); - msg.RunStatus.startRunStatus(builder); - msg.RunStatus.addRid(builder, rid); - const inner = msg.RunStatus.endRunStatus(builder); - - const baseRes = await dispatch.sendAsync(builder, msg.Any.RunStatus, inner); - assert(baseRes != null); - assert(msg.Any.RunStatusRes === baseRes!.innerType()); - const res = new msg.RunStatusRes(); - assert(baseRes!.inner(res) != null); - - if (res.gotSignal()) { - const signal = res.exitSignal(); - return { signal, success: false }; - } else { - const code = res.exitCode(); - return { code, success: code === 0 }; - } -} |