Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn and placeholder arguments #130

Open
herzinger opened this issue Feb 27, 2018 · 5 comments
Open

Yarn and placeholder arguments #130

herzinger opened this issue Feb 27, 2018 · 5 comments

Comments

@herzinger
Copy link

herzinger commented Feb 27, 2018

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
Copy link

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
Copy link

bcomnes commented May 3, 2018

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

@dubbha
Copy link

dubbha commented Dec 6, 2020

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

@kneczaj
Copy link

kneczaj commented Jan 12, 2021

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
Copy link

matthias-ccri commented Sep 15, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants