mysticatea/npm-run-all

Yarn and placeholder arguments

herzinger opened this issue · 5 comments

It's currently working fine, but when using the placeholder for arguments with yarn, you get the following warning:

My scripts:

  "scripts": {
    // [...]
    "bundle:client": "ng build --prod --progress=true --named-chunks=true",
    "bundle:server": "ng build --prod --app 1 --output-hashing=false --progress=true --named-chunks=true",
    "webpack:server": "webpack --config webpack.server.config.js --progress --colors",
    "build:ssr": "run-s \"bundle:** -- {1}\" webpack:server --",
    "start:ssr": "node dist/server",
    // [...]
  },

Yarn warning:

$ yarn build:ssr --env=dev
warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts.

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.

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.