1.0.6 • Published 4 months ago

envine v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Envine:

Envine is a package for easily importing environment configuration files.

Usage:

const envine = require('envine');
envine('./.env'); // loading a regular .env config file
envine('./env.json'); // loading a custom JSON object in environment

Env files:

Env files contains KEY=VALUE entries, separed by a '='. The files may also contain comments, starting with '#'.

In example.env, the comment is simply ignored, and FOO2 is not added to process.env:

FOO=BAR
#Comment
#FOO2=BAR2

API Methods:

envine(fname = '.env'): process.env

> Reads a configuration file 'fname', and parses its content, 
  adding key-value properties to the current 'process.env'.
> It is possible to pass either JSON, ENV, GENV, and any other file 
  using ENV config notation.
> Returns a reference to 'process.env'.

Example usage:

// Declare and initialize the module
const envine = require('envine');

// Example 1:
// Loads a regular '.env' file, containing the property 'FOO=BAR':
// As '.env' is the default, there's no need of passing a filename,
//   but, it beheves the same as "envine('.env')"
envine(); 

// Acessing 'process.env.FOO' is now possible
console.log(process.env.FOO) //=> 'BAR'

// Example 2:
// Loads a custom 'env.json' file: "{ FOO2:'BAR2' }"
envine('env.json');

// Acessing 'process.env.FOO2' is now possible
console.log(process.env.FOO2) //=> 'BAR2'
1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago