Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
/** | ||
* Allow environment variables to take precedence over `val`. | ||
*/ | ||
|
||
module.exports = function(key, val){ | ||
var name = key.toUpperCase().split(' ').join('_'); | ||
return process.env[name] || val; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
var Parser = require('../') | ||
, env = Parser.env; | ||
|
||
describe('env', function(){ | ||
it('should allow setting environment variables', function(){ | ||
env('foo', 'bar').should.equal('bar'); | ||
process.env.FOO = 'baz'; | ||
env('foo', 'bar').should.equal('baz'); | ||
process.env.DEV_UI = 'yes'; | ||
env('dev ui', 'no').should.equal('yes'); | ||
}) | ||
}) |