1
0
mirror of https://github.com/go-task/task.git synced 2025-04-27 12:32:25 +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

@ -88,8 +88,9 @@ func (e *Executor) displayTaskDetails(task string) {
return return
} }
lines := strings.Split(s, "\n") lines := strings.Split(s, "\n")
for _, line := range lines { for i, line := range lines {
if line != "" { notLastLine := i+1 < len(lines)
if notLastLine || line != "" {
e.Logger.Outf(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.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.Contains(t, buff.String(), "details of other-task-with-details")
assert.NotContains(t, buff.String(), "details of 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")
} }

@ -22,3 +22,11 @@ tasks:
details: details of other-task-with-details details: details of other-task-with-details
cmds: cmds:
- echo 'other-task-with-details was executed' - 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