mirror of
https://github.com/go-task/task.git
synced 2024-12-14 10:52:43 +02:00
90613220c6
This seems to fix some of the bugs reported by issues like #114 and #190. Seems that the standard library's os/exec package has some black magic to detect if a writer is an actual *os.File, and some stuff are handled differently, then. Fixes #114 Fixes #190
27 lines
401 B
Go
27 lines
401 B
Go
package output
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
)
|
|
|
|
type Group struct{}
|
|
|
|
func (Group) WrapWriter(w io.Writer, _ string) io.Writer {
|
|
return &groupWriter{writer: w}
|
|
}
|
|
|
|
type groupWriter struct {
|
|
writer io.Writer
|
|
buff bytes.Buffer
|
|
}
|
|
|
|
func (gw *groupWriter) Write(p []byte) (int, error) {
|
|
return gw.buff.Write(p)
|
|
}
|
|
|
|
func (gw *groupWriter) Close() error {
|
|
_, err := io.Copy(gw.writer, &gw.buff)
|
|
return err
|
|
}
|