Skip to content

Commit

Permalink
chore(requires): skip unneeded variable evaluation for requires (#1976
Browse files Browse the repository at this point in the history
)
  • Loading branch information
andreynering authored Dec 30, 2024
1 parent f27daea commit 43f3dce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions requires.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@ import (
"github.com/go-task/task/v3/taskfile/ast"
)

func (e *Executor) areTaskRequiredVarsSet(t *ast.Task, call *ast.Call) error {
func (e *Executor) areTaskRequiredVarsSet(t *ast.Task) error {
if t.Requires == nil || len(t.Requires.Vars) == 0 {
return nil
}

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

var missingVars []string
var notAllowedValuesVars []errors.NotAllowedVar
for _, requiredVar := range t.Requires.Vars {
value, ok := vars.Get(requiredVar.Name)
value, ok := t.Vars.Get(requiredVar.Name)
if !ok {
missingVars = append(missingVars, requiredVar.Name)
} else {
Expand Down
2 changes: 1 addition & 1 deletion task.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (e *Executor) RunTask(ctx context.Context, call *ast.Call) error {
return nil
}

if err := e.areTaskRequiredVarsSet(t, call); err != nil {
if err := e.areTaskRequiredVarsSet(t); err != nil {
return err
}

Expand Down

0 comments on commit 43f3dce

Please sign in to comment.