New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

goenv

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

goenv

Library to load the environment configuration.

latest
Source
npmnpm
Version
1.1.4
Version published
Maintainers
1
Created
Source

Introduction

A set of tools to get env files and save

Start

  • Install
npm i goenv --save
  • Use
const goenv = require('goenv');

const options = 
{
        global: true,
        process: true,
        dirname: __dirname,
        defaultEnv:'dev',
        envName: 'nodeRocks-1.0',
        envPatterns:['dev','int','pre', 'pro'],
        types:['json','js'],
        excludeFiles:['package.json','index.js'],
        excludeFolders:['node_modules']
};

const env = goenv.init(options);

OPTIONS FOR INIT METHOD - example:

  • global: true,
  • process: true,
  • dirname: 'custom_path/to/my/folder'
  • defaultEnv: 'pre'
  • envName: 'nodeRocks-1.0'
  • envPatterns: ['dev','int','pre','pro']
  • types:['json','js'],
  • excludeFiles:['package.json','index.js'],
  • excludeFolders:['node_modules','other_folder']

Global var env

Get the env context in other files after call goenv in index app.

const env = global[myEnvNameInstance];

Extend env

const goenv = require('goenv');
 
const optionsExtend = 
{
global: true,
process: true,
envName: 'nodeRocks-1.0'
};

const extended = goenv.extend({
	propertyExtended: {
		property: 'extended'
	}
}, optionsExtend);
console.log('extended',global['nodeRocks-1.0']);

Added method to remove deep properties


const deleteOptions = {
        global: true,
        process: true,
        envName: 'nodeRocks-1.0',
        key: 'credentials'
};
const deleted = goenv.deleteProps(deleteOptions);

OPTIONS FOR deleteProps METHOD - example:

  • global: true,
  • process: true,
  • envName: 'nodeRocks-1.0',
  • key: 'credentials'

Added method to write an env file


let optionsWriteFile ={
        filename: 'myEnvFile',
        path: __dirname,
        envName: 'nodeRocks-1.0',
        global:true
};

goenv.writeEnvFile(optionsWriteFile, (err,done)=> 
{
        if(err)
        {
                console.log(err);
        };
        console.log(done);
});

OPTIONS FOR writeEnvFile METHOD - example:

  • filename: 'myEnvFile',
  • path: 'path/to/save/the/envFile'
  • envName: 'nodeRocks-1.0',
  • global:true
  • process: false

Keywords

nodejs

FAQs

Package last updated on 11 Feb 2017

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