Skip to content

Makes sure that all required environment variables are set.

License

Notifications You must be signed in to change notification settings

arkeero-forks/check-env

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

check-env CircleCI

Makes sure that all required environment variables are set.

Install

$ npm install --save check-env

Usage

var checkEnv = require('check-env');
checkEnv(['REQUIRED_VAR', 'OTHER_VAR', 'ENV_VAR']);
// => Throws an error if one of the variables aren't set.

CLI Usage

  1. Install as a project dependency as above
  2. Add to a lifecycle script such as prestart
  3. npm start will bail out (exit(1)) with a hard to miss error message if environment variables are not set

Example:

In package.json:

{
  "prestart": "check-env AWS_KEY MONGO_URL",
  "start": "node index.js"
}
$ echo $MONGO_URL
# (nothing)

$ npm start
 ________________________________________
< Missing environment variable MONGO_URL >
 ----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

$ echo $?
1

About

Makes sure that all required environment variables are set.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 65.4%
  • TypeScript 34.6%