Skip to content
A dependency-free utility that prompts you for your project's environment variables.
TypeScript JavaScript
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.npmignore
LICENSE
README.md
package-lock.json
package.json
tsconfig.json
webpack.config.js

README.md

env-prompt

A dependency-free utility that prompts you for your project's environment variables.

How does it work?

On npm install, env-prompt reads environment variables from two files in your project:

  • a distributed file (default: .env.dist)
  • a git ignored local file (default: .env)

Env-prompt will diff these two files, prompting you for any values that exist in your distributed file but not in your local file. Your newly input values will be written to your local environment file.

Getting started

  1. Install env-prompt:
$ npm install -D env-prompt
  1. Add a postinstall hook to your package.json file:
{
  "name": "test",
  "main": "index.js",
+ "scripts": {
+   "postinstall": "env-prompt"
+ },
  "devDependencies": {
    "env-prompt": "^1.0.0"
  }
}
  1. Create a .env.dist file in the same directory as your package.json file:
DB_USER=root
DB_PASS=root123
DB_HOST=127.0.0.1
DB_PORT=3306
DB_NAME=sakila

Env-prompt is now setup, and will be triggered when you run npm install.

Options

-d, --distFile <path>
       Change the distributed environment file env-prompt reads from. (default: .env.dist)

-l, --localFile <path>
       Change the local environment file env-prompt reads from and writes to. (default: .env)

Product backlog

Is your use case not covered? Feel free to open an issue.

You can’t perform that action at this time.