Open herzinger opened 6 years ago
Hi here,
I confirm, I got this issue when using the latest versions of Yarn since the v1. There are no way to pass arguments to the task now from the terminal.
For now, we still have to use these arguments in scripts and wrap them with the script between ' or "
.
Here an example:
"scripts": {
"clean": "rm -rf build/*",
"commons:build": "yarn webpack build",
"lint:js": "eslint '{src,test}/**/*.{js,jsx}'",
"build": "npm-run-all --serial clean lint:js 'commons:build --production'"
}
Run yarn build
will correctly end with yarn webpack build --production
. But there is no way to do it directly using the command yarn build --production
even if I use the --
before (I will get an error for invalid arguments from npm-run-all).
Its very unfortunate yarn has decided to diverge on behavior here.
Made my own yall-scripts tool specifically to address this. It's yarn-friendly, lightweight and does the job.
A partial workaround for this is to use run-s
in package.json in this manner:
{
"scripts: {
"start": "npx run-s \"commandA {@}\" \"commandB {@}\" --"
}
}
Then start
command can be executed with both yarn
and npm
, but it will use npm (not yarn) to run commandA
and commandB
scripts.
Yup, works for me with yarn 1.22.19 on linux:
I want to run
yarn start --port 8234 --cors
And my scripts are:
"start": "run-s build 'serve {@}' --",
"serve": "http-server bundles",
The trailing --
in the start script is key. Also, single quotes work fine instead of double quotes.
It's currently working fine, but when using the placeholder for arguments with yarn, you get the following warning:
My scripts:
Yarn warning:
It might become a problem in the next versions to come.
If I don't use the
--
, as you don't need them in yarn, npm-run-all won't pass the arguments.