1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Merge pull request #5 from sascha-andres/master

Simple cyclic dependency detection
This commit is contained in:
Andrey Nering
2017-03-02 20:39:20 -03:00
committed by GitHub
2 changed files with 20 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ var (
// Tasks constains the tasks parsed from Taskfile
Tasks = make(map[string]*Task)
runTasks = make(map[string]bool)
)
func init() {
@@ -88,6 +90,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}