2023-06-30 03:13:41 +02:00
|
|
|
package task
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-task/task/v3/errors"
|
2023-12-29 22:32:03 +02:00
|
|
|
"github.com/go-task/task/v3/taskfile/ast"
|
2023-06-30 03:13:41 +02:00
|
|
|
)
|
|
|
|
|
2024-08-14 15:37:05 +02:00
|
|
|
func (e *Executor) areTaskRequiredVarsSet(t *ast.Task, call *ast.Call) error {
|
2023-06-30 03:13:41 +02:00
|
|
|
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
|
|
|
|
}
|