Comparing version 0.0.1 to 0.0.2
'use strict'; | ||
module.exports = function () { | ||
if (!process.env) { process.env = {}; } | ||
return process.env; | ||
// Modules | ||
var _ = require('lodash'); | ||
module.exports = function (environment, config) { | ||
// Ensure environment is an object | ||
if (!_.isObject(environment)) { | ||
throw new Error('Fatal: Provided environment is not an object!'); | ||
} | ||
// Merge configuration object, if given | ||
if (_.isObject(config)) { | ||
_.merge(environment, config); | ||
} | ||
return { | ||
get : function (name) { | ||
return environment[name]; | ||
} | ||
}; | ||
}; |
{ | ||
"name": "atmosphere", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Node.js Environment Variable Management", | ||
@@ -10,3 +10,13 @@ "author": "Ryan Lelek <ryanlelek@gmail.com>", | ||
}, | ||
"main": "./lib/index.js" | ||
"main": "./lib/index.js", | ||
"dependencies" : { | ||
"lodash" : "2.4.1" | ||
}, | ||
"devDependencies" : { | ||
"mocha" : "1.20.1", | ||
"should" : "4.0.1" | ||
}, | ||
"scripts" : { | ||
"test" : "make test" | ||
} | ||
} |
@@ -1,4 +0,29 @@ | ||
atmosphere | ||
Atmosphere | ||
========== | ||
Node.js Environment Variable Management | ||
# Why should I use this? | ||
- prevents writing "process.env" everywhere in your project's code. | ||
- increases testability because you can mock different environments (due to above) | ||
# How to Use | ||
## 1) Install via NPM | ||
$ npm install atmosphere | ||
## 2) Initialize | ||
// process.env can be substituted for any object | ||
var atmo = require('atmosphere)(process.env); | ||
## 3) Get Variables | ||
// Access Environment Variables | ||
atmo.get('port'); // 3000 | ||
# Upcoming | ||
- Environment Variable Prefix (MYAPP_PORT -> PORT) | ||
- Auto-capitalization (port -> PORT) | ||
- Replacing spaces with underscores | ||
- Converting the return value to another type ('3000' -> 3000) |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5353
8
63
29
0
1
2
+ Addedlodash@2.4.1
+ Addedlodash@2.4.1(transitive)