Permalink
Browse files

assume underbar suffix for env plugin prefix

  • Loading branch information...
1 parent 8328415 commit 378e85b8265c9f8b9132bdd07e7d8506e4127006 Garrett Johnson committed Nov 7, 2012
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 378e85b

Please sign in to comment.