Skip to content

Task annexes

Ruslan Lopatin edited this page Sep 22, 2020 · 1 revision

Task annex is a task name prefixed with + sign. It does the same as the task, except the task execution.

This can be used e.g. to pass additional parameters to the task IF the task executed.

Note that each task executed once. Still, it can be specified multiple times, each time with its own set of parameters and attributes.

So, for example, with the following package.json file:

{
  "scripts": {
    "test": "run-z +z jest",
    "z": "run-z +test/--runInBand"
  }
}

executing the

yarn test

would always apply a --runInBand option to jest.

+cmd:COMMAND annex

Task names executing the same binary may differ. E.g. test runner task may be called test or test:server. However they both may execute the same command. E.g. jest:

{
  "scripts": {
    "lint": "eslint .",
    "test": "run-z test:client test:server",
    "test:client": "jest -c src/server/jest.config.js",
    "test:server": "jest -c src/client/jest.config.js"
  }
}

A special +cmd:COMMAND annex can be used to specify additional parameters to particular executable. The COMMAND stands for executable name, jest in this case:

yarn test +cmd:jest/--runInBand

The script above would apply --runInBand option to all jest executions. I.e. to both test:client and test:server.

While the following command

yarn test lint +cmd:test,+lint

would execute lint in parallel to test:client and test:server.

Clone this wiki locally