Executes commands using an environment from a .js
file.
npm install --save-dev @supertone/envjs
Usage: envjs [options] <command>
Arguments:
command command to run with env variables
Options:
-f, --file <path> env file path (default: ".env.js")
-e, --env <key=value...> additional env key-value pairs
-h, --help display help
Note:
- You must escape "$" with "\$" for using env variables in command line.
- If you use variadic options(e.g. -e, --env) directly before <command>,
insert "--" between [option] and <command> to distinguish them.
Examples:
envjs echo \$ENV_VAR
envjs -f .env.json echo \$ENV_VAR
envjs -e ENV_VAR=value -- echo \$ENV_VAR
envjs -f .env.json -e ENV_VAR=value -- echo \$ENV_VAR
envjs -e ENV_VAR=value -f .env.json echo \$ENV_VAR
For example in package.json
:
{
"scripts": {
"test": "envjs -f .env.test.js jest",
"start": "envjs -f .env.dev.js http-server -p \\$PORT",
"build": "envjs -e NODE_ENV=production -- webpack"
}
}