Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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
Expand Down
7 changes: 7 additions & 0 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (

// Tasks constains the tasks parsed from Taskfile
Tasks = make(map[string]*Task)

runTasks = make(map[string]bool)
)

func init() {
Expand Down Expand Up @@ -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}
Expand Down