0.1.0 • Published 9 months ago
env-files-codegen v0.1.0
deno-env-codegen
generate typescript fron .env file
Usage
.env
file
# this is a comment
str="value"
nospace=nospace
# a few blank lines
is_true=true
is_false=false
num=123
zero=0
str_start_zero=0123
$ deno run cli -A -i 'path to env file' -o 'path to output file' -t 'deno or node'
output
/************************************
* This file is generated by deno-env-codegen
************************************/
const getEnv = (key: string) => {
const val = process.env[key];
if (val === undefined) {
throw new Error(\`Environment variable "\${key}" is not defined\`);
}
return val;
};
const toNumber = (val: string) => {
return Number(val);
};
const toBoolean = (val: string) => {
return val === "true";
};
// this is a comment
export const str = getEnv("str");
export const nospace = getEnv("nospace");
// a few blank lines
export const is_true = toBoolean(getEnv("is_true"));
export const is_false = toBoolean(getEnv("is_false"));
export const num = toNumber(getEnv("num"));
export const zejro = toNumber(getEnv("zero"));
export const str_start_zero = getEnv("str_start_zero");
0.1.0
9 months ago