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

[rush] Env variables for custom commands #1839

Open
1 of 2 tasks
Nojukubi opened this issue Apr 21, 2020 · 7 comments
Open
1 of 2 tasks

[rush] Env variables for custom commands #1839

Nojukubi opened this issue Apr 21, 2020 · 7 comments
Labels
enhancement The issue is asking for a new feature or design change needs design The next step is for someone to propose the details of an approach for solving the problem
Projects

Comments

@Nojukubi
Copy link

Is this a feature or a bug?

  • Feature
  • Bug

Please describe the actual behavior.
There is no way to predefine Env variables for the custom commands.

What is the expected behavior?
A real-life example where it can be very useful is to disable the stdout output from a large amount of simultaneous processes. Our project contains a few Vue projects that have terminal spinners, so on rush build the console becomes fully filled with redundant messages.

Suggest to have at command-line.json possibility to specify env variables in format:

env: {
  KEY: value
}
@iclanton iclanton added enhancement The issue is asking for a new feature or design change needs design The next step is for someone to propose the details of an approach for solving the problem labels Apr 22, 2020
@iclanton
Copy link
Member

I like this idea. @D4N14L, @octogonz, and I are currently working on redesigning some parts of custom commands and this sounds like a good addition to that plan.

@iclanton iclanton added this to Low priority in Bug Triage Apr 22, 2020
@octogonz
Copy link
Collaborator

A real-life example where it can be very useful is to disable the stdout output from a large amount of simultaneous processes. Our project contains a few Vue projects that have terminal spinners, so on rush build the console becomes fully filled with redundant messages.

How would an environment variable help with this problem?

Also, could you assign the environment variable in the script itself? What's the advantage of having Rush set up the environment?

@Nojukubi
Copy link
Author

How would an environment variable help with this problem?

At build script we can handle the output based on SILENT env variable.

Also, could you assign the environment variable in the script itself?

In this case, the output will also be restricted using `rushx', which most likely is unwanted behavior.

What's the advantage of having Rush set up the environment?

Other case that I can think about is testing. Using rushx test developer definitely want to see reporter output (cases + coverage), but with rush test for 10+ packages interesting is only final package pass/fail and not mess of command outputs.

Of course, there are other ways to solve this particular problem, perhaps the output of the commands can be restricted by an additional property in `command-line.json' that can be configured.

@octogonz
Copy link
Collaborator

octogonz commented Apr 23, 2020

👍 Makes sense. @Nojukubi are you able to create a PR?

@Nojukubi
Copy link
Author

@octogonz, all depends on chosen solution from suggests:

  • env variables (more complex)
  • allow to disable stdout (seems easier)

@crhaglun
Copy link

crhaglun commented Aug 4, 2020

In one of the projects I'm working on, we would like to set some additional node options when running tests, but we don't want to set the options globally, and we would like to avoid updating package.json files for all projects.

Just to check if I'm understanding the suggestion correctly, is the idea that we could declare something like this in command-line.json:

  "commands": [
    {
      "commandKind": "bulk",
      "name": "test",
      "summary": "Runs tests locally.",
      "description": "Run jest for each project.",
      "enableParallelism": true,
      "ignoreDependencyOrder": true,
      "env": {
        "NODE_OPTIONS": "--unhandled-rejections=strict"
       }
    },

@ujwal-setlur
Copy link

Hi, just checking on the status of this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is asking for a new feature or design change needs design The next step is for someone to propose the details of an approach for solving the problem
Projects
Status: Low priority
Bug Triage
  
Low priority
Development

No branches or pull requests

5 participants