Skip to content

Commit

Permalink
refactor: VeryFastCompile for Task list
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaerten committed Feb 9, 2025
1 parent f6ec744 commit df04879
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion task.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (e *Executor) GetTaskList(filters ...FilterFunc) ([]*ast.Task, error) {
// Compile the list of tasks
for i := range tasks {
g.Go(func() error {
compiledTask, err := e.FastCompiledTask(&ast.Call{Task: tasks[i].Task})
compiledTask, err := e.CompiledTaskForTaskList(&ast.Call{Task: tasks[i].Task})
if err != nil {
return err
}
Expand Down
45 changes: 45 additions & 0 deletions variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,51 @@ func (e *Executor) FastCompiledTask(call *ast.Call) (*ast.Task, error) {
return e.compiledTask(call, false)
}

func (e *Executor) CompiledTaskForTaskList(call *ast.Call) (*ast.Task, error) {
origTask, err := e.GetTask(call)
if err != nil {
return nil, err
}

vars, err := e.Compiler.FastGetVariables(origTask, call)
if err != nil {
return nil, err
}

cache := &templater.Cache{Vars: vars}

return &ast.Task{
Task: origTask.Task,
Label: templater.Replace(origTask.Label, cache),
Desc: templater.Replace(origTask.Desc, cache),
Prompt: templater.Replace(origTask.Prompt, cache),
Summary: templater.Replace(origTask.Summary, cache),
Aliases: origTask.Aliases,
Sources: origTask.Sources,
Generates: origTask.Generates,
Dir: origTask.Dir,
Set: origTask.Set,
Shopt: origTask.Shopt,
Vars: vars,
Env: nil,
Dotenv: origTask.Dotenv,
Silent: origTask.Silent,
Interactive: origTask.Interactive,
Internal: origTask.Internal,
Method: origTask.Method,
Prefix: origTask.Prefix,
IgnoreError: origTask.IgnoreError,
Run: origTask.Run,
IncludeVars: origTask.IncludeVars,
IncludedTaskfileVars: origTask.IncludedTaskfileVars,
Platforms: origTask.Platforms,
Location: origTask.Location,
Requires: origTask.Requires,
Watch: origTask.Watch,
Namespace: origTask.Namespace,
}, nil
}

func (e *Executor) compiledTask(call *ast.Call, evaluateShVars bool) (*ast.Task, error) {
origTask, err := e.GetTask(call)
if err != nil {
Expand Down

0 comments on commit df04879

Please sign in to comment.