New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

env-files-codegen

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-files-codegen

Genereate ts code from .env files

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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");

FAQs

Package last updated on 17 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts