Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ekmartin/check-env
Makes sure that all required environment variables are set.
https://github.com/ekmartin/check-env
Last synced: 5 days ago
JSON representation
Makes sure that all required environment variables are set.
- Host: GitHub
- URL: https://github.com/ekmartin/check-env
- Owner: ekmartin
- License: mit
- Created: 2015-02-05T13:01:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T00:16:43.000Z (over 5 years ago)
- Last Synced: 2024-11-06T17:26:43.617Z (12 days ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 16
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# check-env [![CircleCI](https://circleci.com/gh/ekmartin/check-env.svg?style=svg)](https://circleci.com/gh/ekmartin/check-env)
> Makes sure that all required environment variables are set.
## Install
```sh
$ npm install --save check-env
```## Usage
```js
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](https://docs.npmjs.com/misc/scripts) 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:
```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
```