1.0.0 • Published 8 years ago

@niftyco/env v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

@NiftyCo/env

Node.js environment variable management.

Standard Travis CI Coveralls Releases Downloads License

Install

$ npm install --save @niftyco/env

Usage

import env from '@niftyco/env'

console.log(env.get('node_env')) // development

API

.load(file, overwrite = false)

Load a file of environment variables.

env.load('path/to/.env')

.all(filter = () => false)

Filter out variables from the resulting object.

env.all() // { NODE_ENV: 'development', ... }
env.all((val, key) => key === 'NODE_ENV') // { ... }

.has(key)

Check to see if the key exists in the environment.

env.has('node_env') // true

.set(key, val, overwrite = false)

Set a key/object of keys on the environment.

env.set('my_key', 'value') // set
env.set('my_key', 'newValue') // not set
env.set('my_key', 'newValue', true) // set because overwrite is true
env.set({ key1: true, key2: true }) // set both

.get(key,value)

Get the value of key or return value.

env.get('node_env', 'production') // development
env.get('not_set', 'is_now') // is_now
1.0.0

8 years ago