diff --git a/lib/main.js b/lib/main.js index ef74a7bc..46c97f38 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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 } }) diff --git a/test/.env b/test/.env index dde822f5..82e92995 100644 --- a/test/.env +++ b/test/.env @@ -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 diff --git a/test/main.js b/test/main.js index f373ed50..ee77dd99 100644 --- a/test/main.js +++ b/test/main.js @@ -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() + }) }) })