mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.73k stars 239 forks source link

Yarn and placeholder arguments #130

Open herzinger opened 6 years ago

herzinger commented 6 years ago

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.

CPatchane commented 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).

bcomnes commented 6 years ago

Its very unfortunate yarn has decided to diverge on behavior here.

dubbha commented 3 years ago

Made my own yall-scripts tool specifically to address this. It's yarn-friendly, lightweight and does the job.

kneczaj commented 3 years ago

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.

matthias-ccri commented 1 year ago

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.