1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

ignore empty lines on description

This commit is contained in:
jaedle
2019-02-24 11:31:25 +01:00
parent 0164bc21ea
commit b97221cdb2
2 changed files with 11 additions and 5 deletions

14
task.go
View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"strings"
"sync/atomic" "sync/atomic"
"github.com/go-task/task/v2/internal/compiler" "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) { 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) e.Logger.Errf("task: There is no detailed description for task: %s", task)
} else { return
}
e.Logger.Outf(e.Taskfile.Tasks[task].Details) lines := strings.Split(s, "\n")
for _, line := range lines {
if line != "" {
e.Logger.Outf(line)
}
} }
} }

View File

@@ -582,7 +582,7 @@ func TestDetails(t *testing.T) {
buff.Reset() buff.Reset()
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-details"})) 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(), "task-with-details was executed")
assert.NotContains(t, buff.String(), "dependend-task was executed") assert.NotContains(t, buff.String(), "dependend-task was executed")