@@ -29,17 +29,23 @@ type CompilerV3 struct {
2929 muDynamicCache sync.Mutex
3030}
3131
32+ func (c * CompilerV3 ) GetTaskfileVariables () (* taskfile.Vars , error ) {
33+ return c .getVariables (nil , nil , true )
34+ }
35+
3236func (c * CompilerV3 ) GetVariables (t * taskfile.Task , call taskfile.Call ) (* taskfile.Vars , error ) {
33- return c .getVariables (t , call , true )
37+ return c .getVariables (t , & call , true )
3438}
3539
3640func (c * CompilerV3 ) FastGetVariables (t * taskfile.Task , call taskfile.Call ) (* taskfile.Vars , error ) {
37- return c .getVariables (t , call , false )
41+ return c .getVariables (t , & call , false )
3842}
3943
40- func (c * CompilerV3 ) getVariables (t * taskfile.Task , call taskfile.Call , evaluateShVars bool ) (* taskfile.Vars , error ) {
44+ func (c * CompilerV3 ) getVariables (t * taskfile.Task , call * taskfile.Call , evaluateShVars bool ) (* taskfile.Vars , error ) {
4145 result := compiler .GetEnviron ()
42- result .Set ("TASK" , taskfile.Var {Static : t .Task })
46+ if t != nil {
47+ result .Set ("TASK" , taskfile.Var {Static : t .Task })
48+ }
4349
4450 getRangeFunc := func (dir string ) func (k string , v taskfile.Var ) error {
4551 return func (k string , v taskfile.Var ) error {
@@ -74,6 +80,11 @@ func (c *CompilerV3) getVariables(t *taskfile.Task, call taskfile.Call, evaluate
7480 if err := c .TaskfileVars .Range (rangeFunc ); err != nil {
7581 return nil , err
7682 }
83+
84+ if t == nil || call == nil {
85+ return result , nil
86+ }
87+
7788 if err := call .Vars .Range (rangeFunc ); err != nil {
7889 return nil , err
7990 }
0 commit comments