node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

@nod/environment

@nod/environment

Creates merged config object after parsing dotenv and current env variables through javascript.

Supports ES5, ES7, AMD, CommonJS, System and ES6 modules.

Platform

Works in node.js also should(?) work in browser.

GitHub tag Build status Dependency Status Join the chat

Usage:

Installation:

npm install --save @nod/environment

Examples:

import { Environment } from '@nod/environment';
 
let environment = new Environment();
 
let { ENV, config, json } = environment;
 
//config is also environment variables but converted into object notation 
console.log({ config, ENV, json });

Configuring

import { Environment, Configuration as EnvConfig } from '@nod/environment';
import path from 'path';
let environment = new Environment(new EnvConfig {
  silent : true, //should this.console.log issues like missing files or not 
  files : [ // files to look in the path     
    '.env.local',
    '.env.production',
    '.env.test',
    '.env.development',
    '.env',
    '.env.nod'
  ],
  root : path.resolve('.'), // root path for .env files 
  exclude : false //exclude with filter-object for json output 
}, console //console and other deps can replaced); 

Build and develop:

gulp

or

npm run build
npm run watch

Please check available gulp tasks with:

gulp -T

API

All methods have strict type checking please check source code.

ToDo:

  • Gulp tasks as another dependency
  • More detailed docs

Contact:

Send e-mail Join the chat

forthebadge by NOD studios