Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

init-env

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

init-env

initialize environment variables into process.env with a json file

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
1
Created
Source

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

Keywords

env

FAQs

Package last updated on 20 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts