mirror of
https://github.com/go-task/task.git
synced 2025-11-23 22:24:45 +02:00
Fixes some bugs relatated to commands output handling
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
This commit is contained in:
14
task.go
14
task.go
@@ -248,8 +248,18 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi
|
||||
|
||||
stdOut := e.Output.WrapWriter(e.Stdout, t.Prefix)
|
||||
stdErr := e.Output.WrapWriter(e.Stderr, t.Prefix)
|
||||
defer stdOut.Close()
|
||||
defer stdErr.Close()
|
||||
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()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
err := execext.RunCommand(ctx, &execext.RunCommandOptions{
|
||||
Command: cmd.Cmd,
|
||||
|
||||
Reference in New Issue
Block a user