@nodefactory/env-prompt
v1.0.8
Published
A dependency-free utility that prompts you for your project's environment variables.
Downloads
6
Readme
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
- Install env-prompt:
$ npm install -D env-prompt
- Add a postinstall hook to your
package.json
file:
{
"name": "test",
"main": "index.js",
+ "scripts": {
+ "postinstall": "env-prompt"
+ },
"devDependencies": {
"env-prompt": "^1.0.0"
}
}
- Create a
.env.dist
file in the same directory as yourpackage.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.