Skip to content

stevenvachon/dotenv-prompt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotenv-prompt NPM Version Linux Build Windows Build Coverage Status Dependency Monitor

Create and edit .env files via CLI prompts.

Installation

Node.js >= 6 is required. To install, type this at the command line:

npm install dotenv-prompt

Usage

A dual file convention is used, consisting of .env.sample and .env. Both file names and the paths to them can be customized.

.env.sample should contain a template of default values for environmental variables. This file should be committed to your project's repository. Here is an example of such a file:

SOME_VAR=alue

# Comment
ANOTHER_VAR=another value

dotenvPrompt(envPath=".env", envSamplePath=".env.sample", varnames=[])

This function will read the contents of the file at envSamplePath if the file at envPath does not exist. Regardless of which is used, each variable name found within will be prompted for a value.

Optionally, you can specify exactly which should be prompted via varnames.

When all prompts have been answered, a new file will be written (or overwritten) at envPath. Any other custom changes made to the pre-existing file will be preserved.

const dotenvPrompt = require('dotenv-prompt');

dotenvPrompt().catch(error => {
  console.error(error);
  process.exitCode = 1;
});

About

Create and edit .env files via CLI prompts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published