This plugin allows you to run Tool Kit tasks in parallel. By default, Tool Kit tasks run sequentially in the order they are specified in a command.
npm install @dotcom-tool-kit/parallelThis plugin allows you to run Tool Kit tasks in parallel. By default, Tool Kit tasks run sequentially in the order they are specified in a command.
Install @dotcom-tool-kit/parallel as a devDependency in your app:
``sh`
npm install --save-dev @dotcom-tool-kit/parallel
Add the plugin to your Tool Kit configuration:
`yaml`
plugins:
- '@dotcom-tool-kit/parallel'
To run tasks in parallel, pass them in as the tasks option to the Parallel task.
Run Tool Kit tasks in parallel
#### Task options
##### tasks
An array listing the tasks to run in parallel, and the options to run each task with. Each element in the array is an object with a single key and value; the key is the name of the task to run, and the value is the options object for that task. Other tasks' options are documented in their plugin's readme.
###### Example
~~~yaml
commands:
run:local:
- Parallel:
tasks:
- Node:
entry: server/index.js
- Webpack:
watch: true
~~~
##### onError
_optional_
| Value | Description |
|-|-|
| 'wait-for-others' (default) | If any task errors, wait for the other tasks to complete, and print all the errors at the end. |'stop-all'
| | If any task errors, immediately stop the other tasks, and print the error. |
For long-running tasks, e.g. a Node server and Webpack in watch mode, it's possible for one task to error, but its error logging to be buried by the other tasks' output, meaning you might have missed an error and aren't aware that not everything you expect to be running is still running. In these cases, set onError: stop-all; Tool Kit will exit every Parallel task if one of them errors, so you're always in a consistent state and don't miss any errors.
If you're using Parallel to run shorter tasks in parallel as an optimisation, keep this as the default wait-for-others` so every task runs to completion and Tool Kit can show the final results of all the tasks.