env-man
v0.0.2
Published
A simple plugin for managing environment variables in nodejs
Downloads
9
Maintainers
Readme
Env-Manager
Methods
config
- This method will load environment variables into process.env object from the/folder/.env
where folder is a parameter passed to the config method.set
- This method accepts two parameters:parameter 1
key - set on process.env objectparameter 2
the value to be stored on process.env[key]
get
- This method accepts one parameter:key
and returns the value ofprocess.env[key]
;loadFromFile
- Accepts one parameter:filePath
, this method loads environment variables from specified filePath into the process.env object for use in the current executing program.
Installation
npm install env-manager
Examples
Basic Usage
The example below will load environment variables from a .env
file in the current folder.
require("env-manager").config(__dirname);
Set values
const envManager = require("env-manager");
envManager.set("DB_HOST", "...."); // process.env.DB_HOST = "...."
Get values
const envManager = require("env-manager");
console.log(envManager.get("DB_HOST"));
// outputs value of process.env.DB_HOST
Contributions
Your contributions are welcome no matter how small.
License
MIT Licensed.