mirror of
https://github.com/go-task/task.git
synced 2025-01-14 04:35:50 +02:00
should not surpress empty lines expect on last line
This commit is contained in:
parent
399a2b38f3
commit
1ac6f17e6a
5
task.go
5
task.go
@ -88,8 +88,9 @@ func (e *Executor) displayTaskDetails(task string) {
|
||||
return
|
||||
}
|
||||
lines := strings.Split(s, "\n")
|
||||
for _, line := range lines {
|
||||
if line != "" {
|
||||
for i, line := range lines {
|
||||
notLastLine := i+1 < len(lines)
|
||||
if notLastLine || line != "" {
|
||||
e.Logger.Outf(line)
|
||||
}
|
||||
}
|
||||
|
@ -595,4 +595,9 @@ func TestDetails(t *testing.T) {
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "other-task-with-details"}, taskfile.Call{Task: "task-with-details"}))
|
||||
assert.Contains(t, buff.String(), "details of other-task-with-details")
|
||||
assert.NotContains(t, buff.String(), "details of task-with-details")
|
||||
|
||||
buff.Reset()
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-description-containing-empty-line"}))
|
||||
assert.Equal(t, buff.String(), "First line followed by empty line\n\nLast Line\n")
|
||||
|
||||
}
|
||||
|
8
testdata/details/Taskfile.yml
vendored
8
testdata/details/Taskfile.yml
vendored
@ -22,3 +22,11 @@ tasks:
|
||||
details: details of other-task-with-details
|
||||
cmds:
|
||||
- echo 'other-task-with-details was executed'
|
||||
|
||||
task-with-description-containing-empty-line:
|
||||
details: |
|
||||
First line followed by empty line
|
||||
|
||||
Last Line
|
||||
cmds:
|
||||
- exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user