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

fix(workspaces): Passes arguments follwing "--" when running a workspace script #7785

Closed

Conversation

rally25rs
Copy link
Contributor

@rally25rs rally25rs commented Dec 29, 2019

fixes #7776

Summary

Passes arguments following -- when running a workspace script (for example yarn workspace pkg run command -- arg).

Previously these parameters were being trimmed off and ignored.

It seems that in src/cli/index.js we were trimming all params after and including the --, and assigning the remainder to flags.originalArgs which the workspace command was using.

Instead, this PR changes the workspace command to use the args parameter that was already being passed to the command, which includes the args after the --.
The args parameter to the command is also what the yarn run command uses, so it makes sense for yarn run and yarn workspace run to both use args instead of one using args and the other using flags.originalArgs.

Test plan

Since yarn parameter passing in src/cli/index.js is not tested, there are no additional tests.

A manual test can be performed by setting up a basic workspace project:

package.json

{
  "name": "yarn-7776",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}

packages/pkg1/package.json

{
  "name": "pkg1",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "./start.sh"
  }
}

packages/pkg1/start.sh

#!/bin/bash
echo "$@"

then run the yarn command

yarn workspace pkg1 run start -- one two three

The output from the script should be one two three

…ace script

Passes arguments follwing `--` when running a workspace script (`yarn workspace pkg run command --
arg`). Previously these parameters were being trimmed off and ignored.

fixes yarnpkg#7776
@rally25rs rally25rs closed this Dec 29, 2019
@rally25rs
Copy link
Contributor Author

🤦‍♂ this PR basically just undoes what I did in #5534 to fix another bug. back to the drawing board...

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

Successfully merging this pull request may close these issues.

Yarn workspace does not propagate flags
1 participant