mirror of
https://github.com/go-task/task.git
synced 2025-03-21 21:27:07 +02:00
ignore empty lines on description
This commit is contained in:
parent
0164bc21ea
commit
b97221cdb2
14
task.go
14
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user