diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a43c5d3..e73cd26d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +- Add ability to set `error_only: true` on the `group` output mode. This will + instruct Task to only print a command output if it returned with a non-zero + exit code + ([#664](https://github.com/go-task/task/issues/664), [#1022](https://github.com/go-task/task/pull/1022) by @jaedle). - Fixed bug where `.task/checksum` file was sometimes not being created when task also declares a `status:` ([#840](https://github.com/go-task/task/issues/840), [#1035](https://github.com/go-task/task/pull/1035) by @harelwa, [#1037](https://github.com/go-task/task/pull/1037) by @pd93). diff --git a/task.go b/task.go index b2db3079..c6710835 100644 --- a/task.go +++ b/task.go @@ -293,11 +293,9 @@ func (e *Executor) runCommand(ctx context.Context, t *taskfile.Task, call taskfi Stdout: stdOut, Stderr: stdErr, }) - defer func() { - if err := close(err); err != nil { - e.Logger.Errf(logger.Red, "task: unable to close writer: %v", err) - } - }() + if closeErr := close(err); closeErr != nil { + e.Logger.Errf(logger.Red, "task: unable to close writer: %v", closeErr) + } if execext.IsExitError(err) && cmd.IgnoreError { e.Logger.VerboseErrf(logger.Yellow, "task: [%s] command error ignored: %v", t.Name(), err) return nil