env-man

0.0.2 • Public • Published

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.

Package Sidebar

Install

npm i env-man

Weekly Downloads

4

Version

0.0.2

License

MIT

Unpacked Size

4.45 kB

Total Files

4

Last publish

Collaborators

  • spiffgreen