Break out of infinite config loops
This commit is contained in:
parent
cccb9b3903
commit
51513b24a2
@ -26,13 +26,16 @@ import "fmt"
|
||||
|
||||
type config struct {
|
||||
Tasks map[string]task
|
||||
tasksHandled map[string]bool
|
||||
}
|
||||
|
||||
func (this *config) process(srcDir, dstDir, taskName string, flags int) error {
|
||||
this.tasksHandled = make(map[string]bool)
|
||||
|
||||
task, ok := this.Tasks[taskName]
|
||||
if !ok {
|
||||
return fmt.Errorf("task not found %s", taskName)
|
||||
}
|
||||
|
||||
return task.process(srcDir, dstDir, this, flags)
|
||||
return task.process(taskName, srcDir, dstDir, this, flags)
|
||||
}
|
||||
|
11
task.go
11
task.go
@ -30,14 +30,21 @@ type task struct {
|
||||
Cmds []command
|
||||
}
|
||||
|
||||
func (this *task) process(srcDir, dstDir string, conf *config, flags int) error {
|
||||
func (this *task) process(taskName, srcDir, dstDir string, conf *config, flags int) error {
|
||||
handled, ok := conf.tasksHandled[taskName]
|
||||
if ok && handled {
|
||||
return nil
|
||||
}
|
||||
|
||||
conf.tasksHandled[taskName] = true
|
||||
|
||||
for _, depName := range this.Deps {
|
||||
depTask, ok := conf.Tasks[depName]
|
||||
if !ok {
|
||||
return fmt.Errorf("task dependency not found %s", depName)
|
||||
}
|
||||
|
||||
if err := depTask.process(srcDir, dstDir, conf, flags); err != nil {
|
||||
if err := depTask.process(depName, srcDir, dstDir, conf, flags); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user