Skip to content

Instantly share code, notes, and snippets.

@choonkeat
Last active March 17, 2021 12:06
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 choonkeat/a6580019b9089c163ab7779653007fdf to your computer and use it in GitHub Desktop.
Save choonkeat/a6580019b9089c163ab7779653007fdf to your computer and use it in GitHub Desktop.
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