Skip to content

Instantly share code, notes, and snippets.

@fox1t
Created November 22, 2017 10:05
Show Gist options
  • Save fox1t/91c35198e8bd993ad339f09782475699 to your computer and use it in GitHub Desktop.
Save fox1t/91c35198e8bd993ad339f09782475699 to your computer and use it in GitHub Desktop.
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