https://github.com/hacknlove/requirenv
https://github.com/hacknlove/requirenv
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hacknlove/requirenv
- Owner: hacknlove
- License: mit
- Created: 2020-12-18T03:03:41.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-10T17:53:25.000Z (about 5 years ago)
- Last Synced: 2026-03-25T09:25:07.185Z (2 months ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# requirenv
## how to use
1. install it `npm i requirenv`
2. add a file `.env.required.js` to the root of your project
3. prepend `requirenv && ` to the scripts that do you want to fail early if any required environmental variable is missing
4. that's it
## `.env.required.js` example
```
module.exports = [
"foo",
"bar",
"baz",
]
```
## `package.json` example
```
{
...
"scripts": {
"dev": "requirenv .env.local && next dev",
"build": "requirenv && next build",
"start": "requirenv && next start"
},
....
}
```
## How to use it as a library
```javascript
const missing = require('requirenv')
```
that's it. Missing is an array with all the missing variables.
remember to call this after dotenv, if you use it.