1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

Add Preconditions to Tasks

This commit is contained in:
Stephen Prater
2019-05-17 13:13:47 -07:00
parent 6ff9ba9df9
commit bd5882f0f0
14 changed files with 375 additions and 21 deletions

View File

@@ -73,6 +73,7 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
IgnoreError: cmd.IgnoreError,
}
}
}
if len(origTask.Deps) > 0 {
new.Deps = make([]*taskfile.Dep, len(origTask.Deps))
@@ -83,6 +84,16 @@ func (e *Executor) CompiledTask(call taskfile.Call) (*taskfile.Task, error) {
}
}
}
if len(origTask.Precondition) > 0 {
new.Precondition = make([]*taskfile.Precondition, len(origTask.Precondition))
for i, precond := range origTask.Precondition {
new.Precondition[i] = &taskfile.Precondition{
Sh: r.Replace(precond.Sh),
Msg: r.Replace(precond.Msg),
IgnoreError: precond.IgnoreError,
}
}
}
return &new, r.Err()
}