1
0
mirror of https://github.com/go-task/task.git synced 2025-11-27 22:38:20 +02:00

Add flag to allow tasks provided on the command line to be run in parallel

This commit is contained in:
Ross Hammermeister
2019-11-13 13:50:04 -07:00
parent 3084ef129c
commit 27bc1ca5d1
2 changed files with 13 additions and 3 deletions

13
task.go
View File

@@ -41,6 +41,7 @@ type Executor struct {
Silent bool
Dry bool
Summary bool
Parallel bool
Stdin io.Reader
Stdout io.Writer
@@ -77,12 +78,18 @@ func (e *Executor) Run(ctx context.Context, calls ...taskfile.Call) error {
return e.watchTasks(calls...)
}
g, ctx := errgroup.WithContext(ctx)
for _, c := range calls {
if err := e.RunTask(ctx, c); err != nil {
return err
c := c
if e.Parallel {
g.Go(func() error { return e.RunTask(ctx, c) })
} else {
if err := e.RunTask(ctx, c); err != nil {
return err
}
}
}
return nil
return g.Wait()
}
// Setup setups Executor's internal state