stderr PR revisions

This commit is contained in:
rigel rozanski 2017-06-17 18:35:05 -04:00
parent 94c0172618
commit 0a3a08a3bc
2 changed files with 18 additions and 15 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## Develop-Branch changes (unreleased)
BREAKING CHANGES:
- [run] NewBaseService takes the new logger
## 0.2.1 (June 2, 2017) ## 0.2.1 (June 2, 2017)
FEATURES: FEATURES:

View File

@ -68,21 +68,18 @@ func RunCaptureWithArgs(cmd Executable, args []string, env map[string]string) (s
}() }()
// copy the output in a separate goroutine so printing can't block indefinitely // copy the output in a separate goroutine so printing can't block indefinitely
outC := make(chan string) copyStd := func(reader *os.File) *(chan string) {
go func() { stdC := make(chan string)
var buf bytes.Buffer go func() {
// io.Copy will end when we call wOut.Close() below var buf bytes.Buffer
io.Copy(&buf, rOut) // io.Copy will end when we call reader.Close() below
outC <- buf.String() io.Copy(&buf, *reader)
}() stdC <- buf.String()
}()
errC := make(chan string) return stdC
go func() { }
var buf bytes.Buffer outC := copyStd(&rOut)
// io.Copy will end when we call wErr.Close() below errC := copyStd(&rErr)
io.Copy(&buf, rErr)
errC <- buf.String()
}()
// now run the command // now run the command
err = RunWithArgs(cmd, args, env) err = RunWithArgs(cmd, args, env)