diff --git a/task.go b/task.go index 49fa1049..9e4123b4 100644 --- a/task.go +++ b/task.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "strings" "sync/atomic" "github.com/go-task/task/v2/internal/compiler" @@ -81,11 +82,16 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error { } func (e *Executor) displayTaskDetails(task string) { - if e.Taskfile.Tasks[task].Details == "" { + s := e.Taskfile.Tasks[task].Details + if s == "" { e.Logger.Errf("task: There is no detailed description for task: %s", task) - } else { - - e.Logger.Outf(e.Taskfile.Tasks[task].Details) + return + } + lines := strings.Split(s, "\n") + for _, line := range lines { + if line != "" { + e.Logger.Outf(line) + } } } diff --git a/task_test.go b/task_test.go index 6c7c18f0..aedece21 100644 --- a/task_test.go +++ b/task_test.go @@ -582,7 +582,7 @@ func TestDetails(t *testing.T) { buff.Reset() assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) - assert.Equal(t, buff.String(), "details of task-with-details - line 1\n"+"line 2\n"+"line 3\n\n") + assert.Equal(t, buff.String(), "details of task-with-details - line 1\n"+"line 2\n"+"line 3\n") assert.NotContains(t, buff.String(), "task-with-details was executed") assert.NotContains(t, buff.String(), "dependend-task was executed")