ultra-runner icon indicating copy to clipboard operation
ultra-runner copied to clipboard

Variables are not supported / RFC21 compatibility

Open matzeeable opened this issue 3 years ago • 6 comments

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 avatar May 06 '21 14:05 matzeeable

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

nodkz avatar May 13 '21 16:05 nodkz

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

wesselvdv avatar Jun 11 '21 18:06 wesselvdv

Bumping this as an important feature for us as well.

TheSisb avatar Nov 10 '21 21:11 TheSisb

bumping

ghost avatar Nov 25 '21 02:11 ghost

I think I ran into this issue too:

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

Bessonov avatar May 08 '22 16:05 Bessonov

@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"

aparajita avatar Aug 04 '22 23:08 aparajita