mirror of
https://github.com/daylinmorgan/oizys.git
synced 2025-02-23 07:55:50 -06:00
capture the output
This commit is contained in:
parent
fe78716c38
commit
4d16797051
1 changed files with 10 additions and 2 deletions
|
@ -316,6 +316,11 @@ type
|
||||||
BuildResult = object
|
BuildResult = object
|
||||||
duration*: Duration
|
duration*: Duration
|
||||||
successful*: bool
|
successful*: bool
|
||||||
|
stdout*: string
|
||||||
|
stderr*: string
|
||||||
|
|
||||||
|
proc show(br: BuildResult) =
|
||||||
|
error "\n" & formatStdoutStderr(br.stdout, br.stderr)
|
||||||
|
|
||||||
func formatDuration(d: Duration): string =
|
func formatDuration(d: Duration): string =
|
||||||
## convert duration to: X minutes and Y seconds
|
## convert duration to: X minutes and Y seconds
|
||||||
|
@ -331,13 +336,16 @@ proc build(path: string, drv: NixDerivation, rest: seq[string]): BuildResult =
|
||||||
var cmd = "nix build"
|
var cmd = "nix build"
|
||||||
cmd.addArgs path & "^*", "--no-link"
|
cmd.addArgs path & "^*", "--no-link"
|
||||||
cmd.addArgs rest
|
cmd.addArgs rest
|
||||||
let buildCode = runCmd(cmd)
|
let (stdout, stderr, buildCode) = runCmdCapt(cmd, {CaptStdout, CaptStderr})
|
||||||
result.duration = now() - startTime
|
result.duration = now() - startTime
|
||||||
|
result.stdout = stdout
|
||||||
|
result.stderr = stderr
|
||||||
if buildCode == 0:
|
if buildCode == 0:
|
||||||
result.successful = true
|
result.successful = true
|
||||||
info "succesfully built: " & splitDrv(path).name
|
info "succesfully built: " & splitDrv(path).name
|
||||||
else:
|
else:
|
||||||
warn "failed to build: " & splitDrv(path).name
|
error "failed to build: " & splitDrv(path).name
|
||||||
|
show result
|
||||||
info "-> duration: " & formatDuration(result.duration)
|
info "-> duration: " & formatDuration(result.duration)
|
||||||
|
|
||||||
func outputsPaths(drv: NixDerivation): seq[string] =
|
func outputsPaths(drv: NixDerivation): seq[string] =
|
||||||
|
|
Loading…
Add table
Reference in a new issue