Permalink
Browse files

Merge pull request #11 from gjohnson/master

assume underbar suffix for env prefix
  • Loading branch information...
tj committed Nov 8, 2012
2 parents 8328415 + 378e85b commit 88d6f94c3cec9f2302f9cf4116e776b296bad3d0
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/plugins/env.js
  2. +6 −0 test/env.js
View
@@ -6,6 +6,7 @@
module.exports = function(prefix){
prefix = prefix || '';
+ if (prefix && /[^_]$/.test(prefix)) prefix += '_';
return function(key, val){
var name = prefix + key.toUpperCase().split(' ').join('_');
return process.env[name] || val;
View
@@ -20,4 +20,10 @@ describe('env(prefix)', function(){
process.env.NB_DEV_UI = 'yes';
fn('dev ui', 'no').should.equal('yes');
})
+
+ it('should append underbar', function(){
+ var fn = env('NB');
+ process.env.NB_DEV_UI = 'yes';
+ fn('dev ui', 'no').should.equal('yes');
+ });
})

0 comments on commit 88d6f94

Please sign in to comment.