Created
November 22, 2017 10:05
-
-
Save fox1t/91c35198e8bd993ad339f09782475699 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (variables) => { | |
if (!Array.isArray(variables)) { | |
throw new Error('Variables must be an array') | |
} | |
const missing = variables | |
.reduce((missing, current) => !process.env[variable] ? [...missing, current] : missing, []) | |
if (missing.length > 0) { | |
const message = missing.length === 1 ? | |
`Missing environment variable ${missing[0]}`: | |
`Missing environment variables ${missing.join(', ')}` | |
throw new Error(message) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment