feat: caption process stdout and stderr

closes leanprover/lake#54
This commit is contained in:
tydeu 2022-06-01 18:09:39 -04:00
parent c19417b86a
commit 81ea5049af

View file

@ -19,11 +19,15 @@ def proc (args : IO.Process.SpawnArgs) : BuildM PUnit := do
| some cwd => s!"{cmdStr} # in directory {cwd}"
| none => cmdStr
let out ← IO.Process.output args
unless out.stdout.isEmpty do
logInfo out.stdout
unless out.stderr.isEmpty do
logError out.stderr
if out.exitCode != 0 then
let logOutputWith (log : String → BuildM PUnit) := do
unless out.stdout.isEmpty do
log s!"stdout:\n{out.stdout}"
unless out.stderr.isEmpty do
log s!"stderr:\n{out.stderr}"
if out.exitCode = 0 then
logOutputWith logInfo
else
logOutputWith logError
logError s!"external command {args.cmd} exited with status {out.exitCode}"
failure