Skip to content

Commit

Permalink
Merge 0fe5eb6 into 1945a05
Browse files Browse the repository at this point in the history
  • Loading branch information
ravinggenius committed Apr 26, 2018
2 parents 1945a05 + 0fe5eb6 commit f00faeb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function config (options) {

if (options) {
if (options.path) {
dotenvPath = options.path
dotenvPath = options.path.replace(/^file:\/\//, '')
}
if (options.encoding) {
encoding = options.encoding
Expand Down
19 changes: 19 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

require('should')
var path = require('path')
var sinon = require('sinon')
var Lab = require('lab')
var lab = exports.lab = Lab.script()
Expand Down Expand Up @@ -43,6 +44,24 @@ describe('dotenv', function () {
done()
})

it('takes option for path (file url, relative)', function (done) {
var testPath = 'test/.env'
var testUrl = 'file://' + testPath
dotenv.config({path: testUrl})

readFileSyncStub.args[0][0].should.eql(testPath)
done()
})

it('takes option for path (file url, absolute)', function (done) {
var testPath = path.join(__dirname, 'test', '.env')
var testUrl = 'file://' + testPath
dotenv.config({path: testUrl})

readFileSyncStub.args[0][0].should.eql(testPath)
done()
})

it('takes option for encoding', function (done) {
var testEncoding = 'base64'
dotenv.config({encoding: testEncoding})
Expand Down

0 comments on commit f00faeb

Please sign in to comment.