mountenv v0.5.1
mountenv
Features:
- extends dotenv functionality
- supports loading .env files under
CWDor a specific directory - auto loads
.env.devwhenNODE_ENV === 'development'(in addition) - auto loads
.env.prodwhenNODE_ENV === 'production'(in addition) - auto loads
.env.stagingwhenNODE_ENV === 'staging'(in addition) - auto loads
.env.testwhenNODE_ENV === 'test'(in addition)

mountenv.load([dir])
Loads env files in the provided directory and extends current process environment. dir defaults to process.cwd().
require('mountenv').load()mountenv.get([dir])
Loads env files in the provided directory and returns the result object (does NOT extend current process environment). dir defaults to process.cwd().
var result = require('mountenv').get('./config/')mountenv.getAll([dir])
Loads env files in the provided directory and returns the result object including definitions from current process.env (does NOT extend current process environment). dir defaults to process.cwd().
var result = require('mountenv').get('./config/')mountenv.parse(string)
Parses the provided string as an env file and returns the result object.
var env = `
ABC=123
DEF=456
`
var result = require('mountenv').parse(env)Custom env file name
By default, mountenv looks for files starting with .env in the cwd:
├── .env
├── .env.dev
└── .env.prod
└── .env.testIf you want mountenv to look for files with a different prefix, pass {basename:'mycustomname'} as the 2nd argument for any of the above mentioned methods:
require('mountenv').load(null, {basename:'.myenv'})Variable expansion
By default variable expansion is turned on so if you want mountenv to resolve nested variables pass {expand:true} as the 2nd argument for any of the above mentioned methods:
require('mountenv').parse(`
PROJECT_DIR=$HOME/this-project
`, {expand:true}) //-> {PROJECT_DIR: 'Users/thisuser/this-project'}Syntax Rules
License
MIT © Daniel Kalen