mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
Simple cyclic dependency detection
This commit is contained in:
7
task.go
7
task.go
@@ -23,6 +23,8 @@ var (
|
|||||||
|
|
||||||
// Tasks constains the tasks parsed from Taskfile
|
// Tasks constains the tasks parsed from Taskfile
|
||||||
Tasks = make(map[string]*Task)
|
Tasks = make(map[string]*Task)
|
||||||
|
|
||||||
|
runTasks = make(map[string]bool)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -84,6 +86,11 @@ func Run() {
|
|||||||
|
|
||||||
// RunTask runs a task by its name
|
// RunTask runs a task by its name
|
||||||
func RunTask(name string) error {
|
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]
|
t, ok := Tasks[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
return &taskNotFoundError{name}
|
return &taskNotFoundError{name}
|
||||||
|
Reference in New Issue
Block a user