I have an issue when trying to pass arguments to an npm
script with lerna
.
I have a node script that I want to run inside each package in the workspace. lerna
docs suggests the following:
{
"scripts": {
"my-script": "lerna exec -- node \\$LERNA_ROOT_PATH/scripts/my-script.js"
}
}
so now, if I run in the root yarn run my-script
it will run the script inside each package in the workspace.
Sometimes, I need to scope the execution to a specific package. So running this from command line obviously works: lerna exec --scope somepackage -- node \$LERNA_ROOT_PATH/scripts/create-common-scripts.js
.
My question: how can I connect the npm script with the lerna
scope argument. this is not working: yarn run my-script --scope somepackage
, as it sets the argument to the end of the command: lerna exec -- node \\$LERNA_ROOT_PATH/scripts/my-script.js --scope somepackage
.
Thanks!