Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Last active Mar 17, 2021
Embed
What would you like to do?
node scripts/env2file.js > src/Env.elm
function camelize (str) {
let parts = str.replace(/_/g, ' ').toLowerCase().split(/\W+/)
.reduce(function (sum, s) {
if (typeof sum === 'string') sum = [sum]
if (sum[0]) return [...sum, s[0].toUpperCase() + s.slice(1)]
return [s]
})
return (typeof parts === 'string' ? parts : parts.join(''))
}
console.log(`module Env exposing (..)
`)
for (k in process.env) {
let variable = camelize(k)
if (variable) { console.log(`{-| environment variable ${k}\n-}\n` + variable, '=\n ', JSON.stringify(process.env[k]), '\n\n') }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment