0.0.7 • Published 10 years ago

init-env v0.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

init-env

This module will initialize environment variables into process.env using a JSON file

Build Status

Requirements

By default, the module will look for a file in your root directory, .env.json, and use this to read a JSON object of values you want to use as environment variables.

eg.

file: .env.json

{
  "NODE_ENV": "development",
  "API_KEY": "dwdewd232ed23e2321ews12e1"
}

file: server.js

require('init-env')();
console.log(process.env.NODE_ENV) // --> development

Custom Configuration

You can pass custom configs to the module if the defaults don't match what you want to do.

Options

____________________________________________________
property:    logToConsole (Boolean)
default:     false          
description: this will let the module log messages
             about what its doing
____________________________________________________
property:    filePath (String)
default:     './.env.json'                
description: a file path relative to the root of
             the directory eg.  ./.env.json
____________________________________________________
property:    jsonPath (string)
default:     null              
description: property path to where the environment
             vars are located in the JSON
____________________________________________________
property:    overwrite (boolean)
default:     true              
description: when true this decide if the env var
             will be overwritten if already defined
____________________________________________________

eg.

filepath: ./.config/.env.json

{
  "config":{
    "envVars":{
      "NODE_ENV": "development",
      "API_KEY": "dwdewd232ed23e2321ews12e1"
    }
  }
}

file: server.js

require('init-env')({
  logToConsole:true,
  jsonPath:'config.envVars',
  filePath: './.config/.env.json',
  overwrite: true
});
console.log(process.env.NODE_ENV) // --> development

Notes:

  • report issues
  • pull requests are welcome
0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago