Skip to content

Instantly share code, notes, and snippets.

@fox1t
Last active November 22, 2017 14:36
Show Gist options
  • Save fox1t/1e86e7d5ccfaa9f152e8a16f802f6f84 to your computer and use it in GitHub Desktop.
Save fox1t/1e86e7d5ccfaa9f152e8a16f802f6f84 to your computer and use it in GitHub Desktop.
const parse = (env) =>
env
.split(/\r?\n|\r/g)
.reduce((obj, line) => {
const matched = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/)
if (matched != null) {
return Object.assign({}, _.set(obj, matched[1].toLowerCase(),matched[2] || '' ))
}
return obj
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment