Skip to content

Commit

Permalink
Merge 14d6beb into 825c1b2
Browse files Browse the repository at this point in the history
  • Loading branch information
atomaka committed Jan 31, 2017
2 parents 825c1b2 + 14d6beb commit d3e5908
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function parse (src) {
// convert Buffers before splitting into lines and processing
src.toString().split('\n').forEach(function (line) {
// matching "KEY' and 'VAL' in 'KEY=VAL'
var keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/)
var keyValueArr = line.match(/^(export\s)?\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/)
// matched?
if (keyValueArr != null) {
var key = keyValueArr[1]
var key = keyValueArr[2]

// default undefined or missing values to empty string
var value = keyValueArr[2] ? keyValueArr[2] : ''
var value = keyValueArr[3] ? keyValueArr[3] : ''

// expand newlines in quoted values
var len = value ? value.length : 0
Expand Down
1 change: 1 addition & 0 deletions test/.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ RETAIN_INNER_QUOTES={"foo": "bar"}
RETAIN_INNER_QUOTES_AS_STRING='{"foo": "bar"}'
INCLUDE_SPACE=some spaced out string
USERNAME="therealnerdybeast@example.tld"
export EXPORTED=true
5 changes: 5 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ describe('dotenv', function () {
done()
})

it('includes export lines', function (done) {
parsed.should.have.property('EXPORTED')
done()
})

it('respects equals signs in values', function (done) {
parsed.EQUAL_SIGNS.should.eql('equals==')
done()
Expand Down

0 comments on commit d3e5908

Please sign in to comment.