mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
print commands on summary only if commands are present
This commit is contained in:
5
task.go
5
task.go
@@ -98,10 +98,14 @@ func (e *Executor) printTaskSummary(task string) {
|
||||
}
|
||||
|
||||
func printCommands(cmds []*taskfile.Cmd, logger *logger.Logger) {
|
||||
hasCommands := len(cmds) > 0
|
||||
if hasCommands {
|
||||
logger.Outf("")
|
||||
logger.Outf("commands:")
|
||||
for _, c := range cmds {
|
||||
logger.Outf(" - %s", c.Cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) {
|
||||
@@ -114,7 +118,6 @@ func printTaskDependencies(deps []*taskfile.Dep, logger *logger.Logger) {
|
||||
logger.Outf(" - %s", d.Task)
|
||||
}
|
||||
}
|
||||
logger.Outf("")
|
||||
}
|
||||
|
||||
func printTaskSummary(description string, Logger *logger.Logger) {
|
||||
|
17
task_test.go
17
task_test.go
@@ -554,19 +554,6 @@ func TestIncludesCallingRoot(t *testing.T) {
|
||||
tt.Run(t)
|
||||
}
|
||||
|
||||
func TestSummaryParsing(t *testing.T) {
|
||||
const dir = "testdata/summary"
|
||||
|
||||
e := task.Executor{
|
||||
Dir: dir,
|
||||
}
|
||||
assert.NoError(t, e.Setup())
|
||||
|
||||
assert.Equal(t, e.Taskfile.Tasks["task-with-summary"].Summary, "summary of task-with-summary - line 1\nline 2\nline 3\n")
|
||||
assert.Equal(t, e.Taskfile.Tasks["other-task-with-summary"].Summary, "summary of other-task-with-summary")
|
||||
assert.Equal(t, e.Taskfile.Tasks["task-without-summary"].Summary, "")
|
||||
}
|
||||
|
||||
func TestSummary(t *testing.T) {
|
||||
const dir = "testdata/summary"
|
||||
|
||||
@@ -598,6 +585,10 @@ func TestSummary(t *testing.T) {
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary-containing-empty-line"}))
|
||||
assert.Equal(t, readTestFixture(t, dir, "task-with-summary-containing-empty-line.txt"), buff.String())
|
||||
|
||||
buff.Reset()
|
||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-without-commands"}))
|
||||
assert.Equal(t, readTestFixture(t, dir, "task-without-commands.txt"), buff.String())
|
||||
|
||||
}
|
||||
|
||||
func readTestFixture(t *testing.T, dir string, file string) string {
|
||||
|
6
testdata/summary/Taskfile.yml
vendored
6
testdata/summary/Taskfile.yml
vendored
@@ -12,7 +12,7 @@ tasks:
|
||||
- exit 0
|
||||
|
||||
task-without-summary:
|
||||
deps: [dependend-task]
|
||||
deps: [dependend-task-1]
|
||||
cmds:
|
||||
- echo 'task-without-summary was executed'
|
||||
|
||||
@@ -36,3 +36,7 @@ tasks:
|
||||
Last Line
|
||||
cmds:
|
||||
- exit 0
|
||||
|
||||
task-without-commands:
|
||||
summary: summary
|
||||
deps: [dependend-task-1]
|
||||
|
Reference in New Issue
Block a user