From 5e7dce62cb86ec6c823bfe4610cdd25b3ccb0beb Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Thu, 5 Sep 2024 08:26:36 -0500 Subject: [PATCH] hope the buffer doesn't fill up --- pkgs/oizys-nim/src/oizys/exec.nim | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkgs/oizys-nim/src/oizys/exec.nim b/pkgs/oizys-nim/src/oizys/exec.nim index 2f48e70..24320a5 100644 --- a/pkgs/oizys-nim/src/oizys/exec.nim +++ b/pkgs/oizys-nim/src/oizys/exec.nim @@ -19,11 +19,23 @@ proc runCmd*(cmd: string): int = proc runCmdCapt*(cmd: string): tuple[stdout, stderr: string, exitCode: int] = let args = cmd.splitWhitespace() let p = startProcess(args[0], args = args[1..^1], options = {poUsePath}) - result = ( - readAll p.outputStream, - readAll p.errorStream, - waitForExit p - ) + let ostrm = outputStream p + let errstrm = errorStream p + result.exitCode = -1 + var line = newStringOfCap(120) + while true: + if ostrm.readLine(line): + result.stdout.add line & '\n' + if errstrm.readLine(line): + result.stderr.add line & '\n' + result.exitCode = peekExitCode(p) + if result.exitCode != -1: break + + # result = ( + # readAll p.outputStream, + # readAll p.errorStream, + # waitForExit p + # ) close p proc runCmdCaptWithSpinner*(cmd: string, msg: string = ""): tuple[output, err: string] =