Last active
March 17, 2021 12:06
-
-
Save choonkeat/a6580019b9089c163ab7779653007fdf to your computer and use it in GitHub Desktop.
node scripts/env2file.js > src/Env.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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