andrewmclagan/react-env

Question: passing arguments to command

Closed this issue · 6 comments

Hi, I see in the docs that I can do something like react-env <command with arguments> however I can't figure out the right syntax for this.

For example, I can't get the following to work, it doesn't pass --watch to jest:

react-env jest --watch

or any other command where I need to pas a --flag. What am I doing wrong?

Sorry have never tried it with arguments: react-env next dev. Should write tests to cover that. Whats the output?

Why are you attempting to run jest with this lib?

Sorry it was just an example, but I can't pass any flags to my server, eg: --port.

same here... trying to use this with neutrino.js and the default "start": webpack-dev-server --mode development becomes "start": "react-env webpack-dev-server --mode development --dest src/assets" however i don't think the --mode is being passed in since I can see the port changes and other things are not loaded correctly

@donferi I was able to get this working using bash magic... just encapsulate your command arguments in $(). To have the normal output to the terminal add 1>&2 inside. so for me it looks like react-env $(webpack-dev-server --mode development 1>&2) --dest src/

Update: This runs the command correctly but does not create the output env.js files as expected

This has changed in the latest 3.x.x version:

react-env --key APP_ENV -- <command>