diff --git a/config.go b/config.go index 8de9bf7..6ee383c 100644 --- a/config.go +++ b/config.go @@ -25,14 +25,17 @@ package main import "fmt" type config struct { - Tasks map[string]task + 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) } diff --git a/task.go b/task.go index 618a181..848bcf6 100644 --- a/task.go +++ b/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 } }