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

Variables are not supported / RFC21 compatibility #184

Open
matzeeable opened this issue May 6, 2021 · 6 comments
Open

Variables are not supported / RFC21 compatibility #184

matzeeable opened this issue May 6, 2021 · 6 comments

Comments

@matzeeable
Copy link

matzeeable commented May 6, 2021

Hey!

We need to search for an alternative to the yarn berry script runner as it is very slow. I came across this tool, and it looks really promising and it is compatible with Yarn Berry (#137). The scripts are executed very fast! Unfortunately, I stumbled over an issue with variables. Imagine the following:

"scripts": {
    "test1": "echo $COMPOSE_PROJECT_NAME",
    "test2": "COMPOSE_PROJECT_NAME=Hello yarn test1"
}

We need to set the COMPOSE_PROJECT_NAME variable as environment variable because we want to run docker-compose. Is this feature currently not possible or is there another syntax we need to use?

EDIT: I just found out, that you are using cross-spawn to spawn the command to the correct shell. Unfortunately, cross-spawn does not support setting and reading environment variables. For this, cross-env should be used.

RFC 21 compatibility

EDIT: I also noticed that the npm variables like npm_lifecycle_event and npm_package_name are missing. Perhaps it is worth to adopt the coding of @npmcli/run-script to ultra-runner:

  1. Create npm_package_* variables and pass it to the spawn (https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/run-script-pkg.js#L54-L62)
  2. Generate npm_package_* variables (https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/package-envs.js#L7)
  3. Add additional, special variables (https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/make-spawn-args.js#L26-L28)

Regards,
Matthew 😊

@matzeeable matzeeable changed the title Variables are not supported Variables are not supported / RFC21 compatibility May 7, 2021
@nodkz
Copy link

nodkz commented May 13, 2021

I met with the same problem:

"build": "npm run clear && npm run graphql-codegen && NODE_ENV=production next build ./ && npm run intl-build",

Fails with error

Screen Shot 2021-05-13 at 22 38 31

@wesselvdv
Copy link

I'd like to see this supported as well! It makes conditional build steps of specific configuration choices based on ENV variables possible!

@TheSisb
Copy link

TheSisb commented Nov 10, 2021

Bumping this as an important feature for us as well.

@ghost
Copy link

ghost commented Nov 25, 2021

bumping

@Bessonov
Copy link

Bessonov commented May 8, 2022

I think I ran into this issue too:

"build": "NODE_ENV=${NODE_ENV:-production} webpack",

@aparajita
Copy link

@nodkz and everyone else, do it like this, this kind of setup works for me:

"builder": "npm run clear && npm run graphql-codegen && next build ./ && npm run intl-build",
"build": "NODE_ENV=production npm run builder"

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