Skip to content

Commit

Permalink
allow empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
Morriphi committed Sep 11, 2014
1 parent 6f1ec0e commit 9e1bf69
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp/*
log/*
node_modules
npm-debug.log
.idea/
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function (env_file, options) {

lines.forEach(function(line) {
if (!/^\s*\#/i.test(line)) { // ignore comment lines (starting with #).
var key_value = line.match(/^([^=]+)\s*=\s*(.+)$/);
var key_value = line.match(/^([^=]+)\s*=\s*(.*)$/);

var env_key = key_value[1];

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/.env.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

FOO=1
BAR=bar
QUX=
1 change: 1 addition & 0 deletions test/fixtures/.env.exports.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

exports FOO=1
exports BAR=bar
exports QUX=
12 changes: 6 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');

process.env.FOO = 'foo2';

Expand All @@ -151,7 +151,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');

process.env.FOO = 'foo2';

Expand All @@ -162,7 +162,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
},

'("./fixtures/.env.3")': function () {
Expand Down Expand Up @@ -255,7 +255,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');

process.env.FOO = 'foo2';

Expand All @@ -266,7 +266,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');

process.env.FOO = 'foo2';

Expand All @@ -277,7 +277,7 @@ module.exports = {
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
},

'("./fixtures/.env.exports.3")': function () {
Expand Down

0 comments on commit 9e1bf69

Please sign in to comment.