1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/vendor/github.com/shurcooL/go/pipeutil/dir.go

29 lines
715 B
Go
Raw Normal View History

2017-10-03 21:43:55 +03:00
package pipeutil
import "gopkg.in/pipe.v2"
// OutputDir is identical to pipe.Output, except it sets the starting dir.
func OutputDir(p pipe.Pipe, dir string) ([]byte, error) {
outb := &pipe.OutputBuffer{}
s := pipe.NewState(outb, nil)
s.Dir = dir
err := p(s)
if err == nil {
err = s.RunTasks()
}
return outb.Bytes(), err
}
// DividedOutputDir is identical to pipe.DividedOutput, except it sets the starting dir.
func DividedOutputDir(p pipe.Pipe, dir string) (stdout []byte, stderr []byte, err error) {
outb := &pipe.OutputBuffer{}
errb := &pipe.OutputBuffer{}
s := pipe.NewState(outb, errb)
s.Dir = dir
err = p(s)
if err == nil {
err = s.RunTasks()
}
return outb.Bytes(), errb.Bytes(), err
}