1.0.4 • Published 3 years ago

propsenv v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Overview

This is base on the https://www.npmjs.com/package/dotenv and support multiple environments file.

Install

# with npm 
npm install propsenv
 
# or with Yarn 
yarn add propsenv

Usage

As early as possible in your application, require and configure propsenv.

## default
require('propsenv')()

## with options
require('propsenv')({
  debug: true,
  path: './your_env_path',
  encoding: 'utf-8'
})

Create a env_<env>.properties file in the root/env/ directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE. For example:

HOST=localhost.local
USER=root
PASS=pass
ARRAY=1,item,3, true

You can also create multiple env_<env>.properties file in the directory.

# <root>/env

env_dev.properties
env_test.properties
env_prod.properties

Then execute your start script before with NODEENV=, you will get the configured variables in to env.properties file by process.env.HOST, process.env.USER, process.env.PASS

NODE_ENV=test node your_script.js