Skip to content

Commit

Permalink
Merge a226ac2 into 46ec97d
Browse files Browse the repository at this point in the history
  • Loading branch information
becdot committed Nov 28, 2017
2 parents 46ec97d + a226ac2 commit 4e1542d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ function parse (src) {
// remove any surrounding quotes and extra spaces
value = value.replace(/(^['"]|['"]$)/g, '').trim()

// set booleans appropriately instead of boolean strings
if (value === 'true') {
value = true
} else if (value === 'false') {
value = false
}

obj[key] = value
}
})
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"
FALSEY_VALUE=false
5 changes: 5 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,10 @@ describe('dotenv', function () {
parsed.should.have.property('USERNAME', 'therealnerdybeast@example.tld')
done()
})

it('parses booleans correctly', function (done) {
parsed.should.have.property('FALSEY_VALUE', false)
done()
})
})
})

0 comments on commit 4e1542d

Please sign in to comment.