Get and set values on process.env using a namespace.
Follow this project's author, Jon Schlinkert, for updates on this project and others.
Install with npm:
$ npm install --save env-cache
This library makes it easier to get and set values on process.env. Anywhere you need to access the process.env values, just create a new instance with the namespace you want to access.
var EnvCache = require('env-cache');
// the given namespace is automatically uppercased
var env = new EnvCache('your-namespace');
env.set('production', true);
console.log(env.get('production'));
//=> 'true'
Create an instance of EnvCache with the given namespace. The namespace is automatically uppercased and is then used by the .set and .get methods to prefix keys.
Params
namespace {String}: The namespace to use on process.env.Example
var env = new EnvCache('foo');
Set a value on your process.env namespace.
Params
key {String}val {any}Example
env.set('dev', true);
console.log(process.env.FOO_DEV);
//=> true
Get a value from your process.env namespace.
Params
key {String}Example
env.set('dev', true);
console.log(env.get('dev'));
//=> true
Returns the true boolean if the value of key is the string "true".
Params
key {String}Example
env.set('dev', true);
console.log(env.enabled('dev'));
//=> true
Returns the false boolean if the value of key is the string "false".
Params
key {String}Example
env.set('dev', true);
console.log(env.disabled('dev'));
//=> false
env.set('dev', false);
console.log(env.disabled('dev'));
//=> true
You might also be interested in these projects:
get, set, del, and has methods for node.js/javascript projects. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on August 27, 2017.