Skip to content

Commit

Permalink
fix(env): consider empty env variable as defined
Browse files Browse the repository at this point in the history
  • Loading branch information
FGRibreau committed Apr 22, 2015
1 parent a2cf4cd commit 5e972f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/common-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function env(logger, options) {

return {
getOrElse: function (key, def) {
if (process.env[key]) {
if (_.has(process.env, key)) {
var val = _.isNumber(def) ? toInt(process.env[key]) : process.env[key];

if (seemsBoolean(val)) {
Expand Down
2 changes: 2 additions & 0 deletions test/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('env', function () {
process.env.AMQP_LOGIN = 'plop';
process.env.AMQP_CONNECT = 'tRue';
process.env.AMQP_CONNECT2 = 'false';
process.env.AMQP_PASSWORD = '';
process.env['PLOP_API[0]_A'] = 3;
});

Expand Down Expand Up @@ -75,6 +76,7 @@ describe('env', function () {
});

t.strictEqual(config.AMQP.LoGiN, 'plop');
t.strictEqual(config.AMQP.PASSWORD, '');
t.strictEqual(config.AMQP.PORT, 5672);
t.strictEqual(config.AMQP.PLOP.ok.heyheyhey, true);
t.strictEqual(config.AMQP.connect, true);
Expand Down

0 comments on commit 5e972f3

Please sign in to comment.