Skip to content

Instantly share code, notes, and snippets.

@blogui91
Last active April 8, 2020 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blogui91/b7f9befd003afb44eeb3201e5884de3e to your computer and use it in GitHub Desktop.
Save blogui91/b7f9befd003afb44eeb3201e5884de3e to your computer and use it in GitHub Desktop.
// config/envparser.js
const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config().parsed
module.exports = function () {
// Let's stringify our variables
for (key in parsedEnv) {
if (typeof parsedEnv[key] === 'string') {
parsedEnv[key] = JSON.stringify(parsedEnv[key])
}
}
return parsedEnv
}
@kepi0809
Copy link

kepi0809 commented Apr 8, 2020

does it work w/o defining it first? (const key in …) didn't try because eslint was throwing error for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment