json_env
is dotenv, but with JSON.
json_env
loads an environment variables from a file called .env.json
in the current directory and starts a subprocess
with them.
Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.
.env.json:
json
{
"NODE_ENV": "DEV",
"MY_USER": "Carl",
"NUM_USERS": 10,
"nested": {
"hello": "world",
"boo": "far"
}
}
Shell: ```shell $ json_env env
MYUSER=Carl NODEENV=DEV NUM_USERS=10 nested={"boo":"far","hello":"world"} [...] ```
Additional command line arguments that are passed to json_env
are forwarded to the child process:
Shell: ```shell
$ json_env echo "Test"
Test ```