I have yarn test
, which is actually composed of two subcommands yarn test:root && yarn test:packages
. Both run jest (but packages does it indirectly using lerna exec). I want to be able to type yarn test -t=Pattern
from the terminal and have both sub-commands append -t=Pattern
to the end. lerna exec -- "yarn test"
doesnt seem to have a way to do this.
I have a monorepo, that uses lerna exec
to run yarn test
on each lerna package.
Given:
"test": "yarn run test:packages $@ && yarn run test:root $@",
"test:packages": "lerna exec -- yarn test $@", // No args passed
"test:root": "jest ./tests/Storyshots.jest.js $@", // Args passed
I want to be able to do something like
yarn test --updateSnapshot
and for --updateSnapshot
to be appended to yarn test
run through lerna exec
With a regular npm script (see test:root
) using $@
works fine. The lerna docs don't mention any way to do this.
Update
I think the easiest way will be to write a script which composes the args and the commands. This will need to be used in all lerna packages.
You are able to pass command line args to inner commands by using --
. Using --
will signify the end of the options for the current command and allow options to get passed to the inner commands.
So for this situations we need to escape three times:
test:packages
test:root
yarn test -- -- -- -t=Pattern
To append args, you just use something like lerna exec 'yarn test --updateSnapshot'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With