DavidSampson / dotenv-cli

A cli to load dotenv files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dotenv-cli

Installing

NPM

$ npm install -g dotenv-cli

Yarn

$ yarn global add dotenv-cli

Usage

$ dotenv <command with arguments>

This will load the variables from the .env file in the current working directory and then run the command (using the new set of environment variables).

Custom .env files

Another .env file could be specified using the -e flag:

$ dotenv -e .env2 <command with arguments>

Multiple .env files can be specified, and will be processed in order:

$ dotenv -e .env3 -e .env4 <command with arguments>

Check env variable

If you want to check the value of an environment variable, use the -p flag

$ dotenv -p NODE_ENV

Flags to the underlying command

If you want to pass flags to the inner command use -- after all the flags to dotenv-cli.

E.g. the following command without dotenv-cli:

mvn exec:java -Dexec.args="-g -f"

will become the following command with dotenv-cli:

$ dotenv -- mvn exec:java -Dexec.args="-g -f"

or in case the env file is at .my-env

$ dotenv -e .my-env -- mvn exec:java -Dexec.args="-g -f"

Variable expansion

We support expanding env variables inside .env files (See dotenv-expand npm package for more information)

For example:

IP=127.0.0.1
PORT=1234
APP_URL=http://${IP}:${PORT}

Using the above example .env file, process.env.APP_URL would be http://127.0.0.1:1234.

License

MIT

About

A cli to load dotenv files

License:MIT License


Languages

Language:JavaScript 100.0%