From ea2e86e3983046d824c2a4c6b72ebee42502cc2a Mon Sep 17 00:00:00 2001 From: Sascha Andres Date: Thu, 2 Mar 2017 09:38:23 +0100 Subject: [PATCH] Simple cyclic dependency detection --- task.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/task.go b/task.go index ceb70e5f..e0eab8db 100644 --- a/task.go +++ b/task.go @@ -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}