env-prompt

2.0.3 • Public • Published

env-prompt

Env-prompt is a Node.js utility that enables teams to seamlessly keep their environment variables in sync.

You simply provide two .env files:

  • a distributed file (default: .env.dist) committed to version control
  • a git ignored local file (default: .env)

As new variables are added to the distributed file, your team is prompted for their values.

Getting started

  1. Install env-prompt:
npm install -D env-prompt
  1. Add the env-prompt command to a script in your package.json file:
{
  "name": "test",
  "main": "index.js",
+ "scripts": {
+   "postinstall": "env-prompt"
+ },
  "devDependencies": {
    "env-prompt": "^2.0.0"
  }
}
  1. Create a .env.dist file in the same directory as your package.json file:
API_HOSTNAME=https://example.com
API_USER=api_user
API_PASS=myP4$$w0rd

Env-prompt is now set up to diff your .env and .env.dist files, and will be triggered when you run npm install.

Command-line interface

Synopsis

[CI=<true|false>] npx env-prompt
    [-d|--distFile <path>]
    [-l|--localFile <path>]
    [-p|--prompts <true|false>]
    [-a|--allowDuplicates]
    [-n|--newlineType <unix|windows>]

Arguments

-d <path>

--distFile <path>

Default: .env.dist
This is the .env file that env-prompt will scan for new environment variables. It is recommended that you commit this file to version control.

-l <path>

--localFile <path>

Default: .env
This is the .env file for your local environment. When prompted for new variables, the input values will be written here. It is recommended that you add this file to the .gitignore of your project.

-p <true|false>

--prompts <true|false>

Default: true
When setting --prompts false, env-prompt will run headlessly and will not prompt the user when new variables are detected. The default value from the distributed file will be written for new variables.

-a

--allowDuplicates

By default, an error is raised when duplicate variable declarations are found. The presence of this flag supresses this error.

-n <unix|windows>

--newlineType <unix|windows>

Default (on non-windows systems): unix
Default (on windows): windows
Determines how newlines will be written to disk. For unix, \n will be used. For windows, \r\n will be used. This argument only impacts how newlines are written to disk. Regardless of this value, \n, \r\n, and \r are all read from disk as newlines.

Variables

CI=<true|false>

Default: false
Indicates whether or not env-prompt is being run by continous integration. Setting CI=true is equivalent to --prompts false.

/env-prompt/

    Package Sidebar

    Install

    npm i env-prompt

    Weekly Downloads

    163

    Version

    2.0.3

    License

    MIT

    Unpacked Size

    473 kB

    Total Files

    45

    Last publish

    Collaborators

    • bkotos