1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Fix bug with STDOUT and STDERR in the "group" output mode

Took the oportunity to refactor a bit how we handle closing of the streams.

Fixes #779
This commit is contained in:
Andrey Nering
2022-07-06 10:43:32 -03:00
parent de45e48c37
commit e36c77aaf3
7 changed files with 40 additions and 37 deletions

15
task.go
View File

@@ -449,19 +449,10 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi
if err != nil {
return fmt.Errorf("task: failed to get variables: %w", err)
}
stdOut := outputWrapper.WrapWriter(e.Stdout, t.Prefix, outputTemplater)
stdErr := outputWrapper.WrapWriter(e.Stderr, t.Prefix, outputTemplater)
stdOut, stdErr, close := outputWrapper.WrapWriter(e.Stdout, e.Stderr, t.Prefix, outputTemplater)
defer func() {
if _, ok := stdOut.(*os.File); !ok {
if closer, ok := stdOut.(io.Closer); ok {
closer.Close()
}
}
if _, ok := stdErr.(*os.File); !ok {
if closer, ok := stdErr.(io.Closer); ok {
closer.Close()
}
if err := close(); err != nil {
e.Logger.Errf(logger.Red, "task: unable to close writter: %v", err)
}
}()