npm.io
0.0.2 • Published 5 years ago

env-man

Licence
MIT
Version
0.0.2
Deps
0
Size
4 kB
Vulns
0
Weekly
0
Stars
2

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 object
    • parameter 2 the value to be stored on process.env[key]
  • get - This method accepts one parameter: key and returns the value of process.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.

Keywords