1
0
mirror of https://github.com/go-task/task.git synced 2025-08-08 22:36:57 +02:00

refactor: VeryFastCompile for Task list

This commit is contained in:
Valentin Maerten
2025-02-09 20:01:35 +01:00
parent bc85be2c47
commit e639dfae32
2 changed files with 46 additions and 1 deletions

View File

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

View File

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