1
0
mirror of https://github.com/go-task/task.git synced 2025-03-17 21:08:01 +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
commit f7d119f544
2 changed files with 20 additions and 0 deletions

View File

@ -88,6 +88,19 @@ css:
- npm run buildcss
```
Each task can only be run once. If it is included from another dependend task causing
a cyclomatic dependency, execution will be stopped.
```yml
task1:
deps: [task2]
task2:
deps: [task1]
```
Will stop at the moment the dependencies of `task2` are executed.
### Prevent task from running when not necessary
If a task generates something, you can inform Task the source and generated

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}