Skip to content

Commit b08b354

Browse files
authored
Merge pull request #283 from paulvarache/desc-tmpl
Compile tasks before printing help or summary
2 parents 32b097b + 7453e68 commit b08b354

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

help.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ func (e *Executor) tasksWithDesc() (tasks []*taskfile.Task) {
2929
tasks = make([]*taskfile.Task, 0, len(e.Taskfile.Tasks))
3030
for _, task := range e.Taskfile.Tasks {
3131
if task.Desc != "" {
32+
compiledTask, err := e.CompiledTask(taskfile.Call{Task: task.Task})
33+
if err == nil {
34+
task = compiledTask
35+
}
3236
tasks = append(tasks, task)
3337
}
3438
}

internal/summary/summary.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import (
99

1010
func PrintTasks(l *logger.Logger, t *taskfile.Taskfile, c []taskfile.Call) {
1111
for i, call := range c {
12-
printSpaceBetweenSummaries(l, i)
12+
PrintSpaceBetweenSummaries(l, i)
1313
PrintTask(l, t.Tasks[call.Task])
1414
}
1515
}
1616

17-
func printSpaceBetweenSummaries(l *logger.Logger, i int) {
17+
func PrintSpaceBetweenSummaries(l *logger.Logger, i int) {
1818
spaceRequired := i > 0
1919
if !spaceRequired {
2020
return

task.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
7070
}
7171

7272
if e.Summary {
73-
summary.PrintTasks(e.Logger, e.Taskfile, calls)
73+
for i, c := range calls {
74+
compiledTask, err := e.CompiledTask(c)
75+
if err != nil {
76+
return nil
77+
}
78+
summary.PrintSpaceBetweenSummaries(e.Logger, i)
79+
summary.PrintTask(e.Logger, compiledTask)
80+
}
7481
return nil
7582
}
7683

variables.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
2525
new := taskfile.Task{
2626
Task: origTask.Task,
2727
Desc: r.Replace(origTask.Desc),
28+
Summary: r.Replace(origTask.Summary),
2829
Sources: r.ReplaceSlice(origTask.Sources),
2930
Generates: r.ReplaceSlice(origTask.Generates),
3031
Status: r.ReplaceSlice(origTask.Status),

0 commit comments

Comments
 (0)