mirror of
https://github.com/daylinmorgan/oizys.git
synced 2025-02-23 03:45: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
|
||||
duration*: Duration
|
||||
successful*: bool
|
||||
stdout*: string
|
||||
stderr*: string
|
||||
|
||||
proc show(br: BuildResult) =
|
||||
error "\n" & formatStdoutStderr(br.stdout, br.stderr)
|
||||
|
||||
func formatDuration(d: Duration): string =
|
||||
## 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"
|
||||
cmd.addArgs path & "^*", "--no-link"
|
||||
cmd.addArgs rest
|
||||
let buildCode = runCmd(cmd)
|
||||
let (stdout, stderr, buildCode) = runCmdCapt(cmd, {CaptStdout, CaptStderr})
|
||||
result.duration = now() - startTime
|
||||
result.stdout = stdout
|
||||
result.stderr = stderr
|
||||
if buildCode == 0:
|
||||
result.successful = true
|
||||
info "succesfully built: " & splitDrv(path).name
|
||||
else:
|
||||
warn "failed to build: " & splitDrv(path).name
|
||||
error "failed to build: " & splitDrv(path).name
|
||||
show result
|
||||
info "-> duration: " & formatDuration(result.duration)
|
||||
|
||||
func outputsPaths(drv: NixDerivation): seq[string] =
|
||||
|
|
Loading…
Add table
Reference in a new issue