Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.
/ envjs Public archive

Executes commands using an environment from a .js file.

Notifications You must be signed in to change notification settings

supertone-inc/envjs

Repository files navigation

@supertone/envjs

npm (scoped) Test codecov

Executes commands using an environment from a .js file.

Installation

npm install --save-dev @supertone/envjs

Usage

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"
  }
}