1
0
mirror of https://github.com/go-task/task.git synced 2025-03-05 15:05:42 +02:00

Simple cyclic dependency detection

This commit is contained in:
Sascha Andres 2017-03-02 09:38:23 +01:00
parent 1576943702
commit ea2e86e398

View File

@ -23,6 +23,8 @@ var (
// Tasks constains the tasks parsed from Taskfile
Tasks = make(map[string]*Task)
runTasks = make(map[string]bool)
)
func init() {
@ -84,6 +86,11 @@ func Run() {
// RunTask runs a task by its name
func RunTask(name string) error {
if _, found := runTasks[name]; found {
return &taskRunError{taskName: name, err: fmt.Errorf("Cyclic dependency detected")}
}
runTasks[name] = true
t, ok := Tasks[name]
if !ok {
return &taskNotFoundError{name}