From d5e820f9b091da6e63b37d71e3e2cbfd8e4c4277 Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Sat, 10 Feb 2024 09:21:15 -0500 Subject: [PATCH] Implement ExecStack.read --- src/exec-stack.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/exec-stack.ts b/src/exec-stack.ts index 8d3d701..806da02 100644 --- a/src/exec-stack.ts +++ b/src/exec-stack.ts @@ -14,12 +14,23 @@ export class ExecStack { .concat(args); } - async exec(args: string[]): Promise { - return await exec.exec("stack", this.stackArguments.concat(args)); + async exec(args: string[], options?: exec.ExecOptions): Promise { + return await exec.exec("stack", this.stackArguments.concat(args), options); } - async read(_args: string[]): Promise { - return "TODO"; + async read(args: string[]): Promise { + let stdout = ""; + + const options: exec.ExecOptions = { + listeners: { + stdout: (data: Buffer) => { + stdout += data.toString(); + }, + }, + }; + + await this.exec(args, options); + return stdout; } async parse(args: string[], f: (stdout: string) => A): Promise {