@marknotton/env
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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)

Readme

Keywords

Package Sidebar

Install

npm i @marknotton/env

Weekly Downloads

1,272

Version

2.0.0

License

MIT

Unpacked Size

7.19 kB

Total Files

5

Last publish

Collaborators

  • marknotton