1
0
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:
jaedle 2019-02-24 11:58:44 +01:00
parent 399a2b38f3
commit 1ac6f17e6a
3 changed files with 16 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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")
}

View File

@ -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