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:
parent
1576943702
commit
ea2e86e398
7
task.go
7
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}
|
||||
|
Loading…
x
Reference in New Issue
Block a user