ultra-runner
ultra-runner copied to clipboard
Variables are not supported / RFC21 compatibility
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
:
- 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) - Generate
npm_package_*
variables (https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/package-envs.js#L7) - Add additional, special variables (https://github.com/npm/run-script/blob/47a4d539fb07220e7215cc0e482683b76407ef9b/lib/make-spawn-args.js#L26-L28)
Regards, Matthew 😊
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

I'd like to see this supported as well! It makes conditional build steps of specific configuration choices based on ENV variables possible!
Bumping this as an important feature for us as well.
bumping
I think I ran into this issue too:
"build": "NODE_ENV=${NODE_ENV:-production} webpack",
@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"