mirror of
https://github.com/go-task/task.git
synced 2024-12-04 10:24:45 +02:00
5e9851f42f
* feat: update minimum version to 1.22 * refactor: use int range iterator * refactor: loop variables * refactor: replace slicesext.FirstNonZero with cmp.Or * refactor: use slices.Concat instead of append * fix: unused param * fix: linting
34 lines
646 B
Go
34 lines
646 B
Go
package task
|
|
|
|
import (
|
|
"github.com/go-task/task/v3/errors"
|
|
"github.com/go-task/task/v3/taskfile/ast"
|
|
)
|
|
|
|
func (e *Executor) areTaskRequiredVarsSet(t *ast.Task, call *ast.Call) 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
|
|
for _, requiredVar := range t.Requires.Vars {
|
|
if !vars.Exists(requiredVar) {
|
|
missingVars = append(missingVars, requiredVar)
|
|
}
|
|
}
|
|
|
|
if len(missingVars) > 0 {
|
|
return &errors.TaskMissingRequiredVars{
|
|
TaskName: t.Name(),
|
|
MissingVars: missingVars,
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|