2.0.0 • Published 11 months ago

@marknotton/env v2.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
11 months ago

Env

Made For NPM

Add, edit, delete and read variables from a .env file.

Installation

npm i @marknotton/env --save-dev
import Env from '@marknotton/env'

Usage

Basic usage

const env = new Env()

You can defined a different .env file by passing in a string that is relative path.

const env = new Env('.env.example')

Methods

Set Variable

Add a variable and value to the .env file. Variable will be created if it isn't found. It will be overwritten if it does exists.

env.set(variable, value)

Delete Variable

Delete variable from .env file.

env.delete(variable)

Toggle Variable

Add a 'true' boolean to the given vairable, or remove it entirely if it's false.

env.toggleBoolean(variable, true)  // Add's VARIABLE=true 
env.toggleBoolean(variable, false) // Removes VARIABLE=true entirely 

Get Variable

Get variable from .env file.

env.get(variable)

Has Variable

Check if a variable exists.

env.has(variable)