@@ -13,12 +13,27 @@ import (
1313// CompiledTask returns a copy of a task, but replacing variables in almost all
1414// properties using the Go template package.
1515func (e * Executor ) CompiledTask (call taskfile.Call ) (* taskfile.Task , error ) {
16+ return e .compiledTask (call , true )
17+ }
18+
19+ // FastCompiledTask is like CompiledTask, but it skippes dynamic variables.
20+ func (e * Executor ) FastCompiledTask (call taskfile.Call ) (* taskfile.Task , error ) {
21+ return e .compiledTask (call , false )
22+ }
23+
24+ func (e * Executor ) compiledTask (call taskfile.Call , evaluateShVars bool ) (* taskfile.Task , error ) {
1625 origTask , ok := e .Taskfile .Tasks [call .Task ]
1726 if ! ok {
1827 return nil , & taskNotFoundError {call .Task }
1928 }
2029
21- vars , err := e .Compiler .GetVariables (origTask , call )
30+ var vars * taskfile.Vars
31+ var err error
32+ if evaluateShVars {
33+ vars , err = e .Compiler .GetVariables (origTask , call )
34+ } else {
35+ vars , err = e .Compiler .FastGetVariables (origTask , call )
36+ }
2237 if err != nil {
2338 return nil , err
2439 }
@@ -59,16 +74,18 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
5974 new .Env = & taskfile.Vars {}
6075 new .Env .Merge (r .ReplaceVars (e .Taskfile .Env ))
6176 new .Env .Merge (r .ReplaceVars (origTask .Env ))
62- err = new .Env .Range (func (k string , v taskfile.Var ) error {
63- static , err := e .Compiler .HandleDynamicVar (v , new .Dir )
77+ if evaluateShVars {
78+ err = new .Env .Range (func (k string , v taskfile.Var ) error {
79+ static , err := e .Compiler .HandleDynamicVar (v , new .Dir )
80+ if err != nil {
81+ return err
82+ }
83+ new .Env .Set (k , taskfile.Var {Static : static })
84+ return nil
85+ })
6486 if err != nil {
65- return err
87+ return nil , err
6688 }
67- new .Env .Set (k , taskfile.Var {Static : static })
68- return nil
69- })
70- if err != nil {
71- return nil , err
7289 }
7390
7491 if len (origTask .Cmds ) > 0 {
0 commit comments