Skip to content

Commit

Permalink
Merge 1ef00c8 into 825c1b2
Browse files Browse the repository at this point in the history
  • Loading branch information
ckiickA committed Jan 5, 2017
2 parents 825c1b2 + 1ef00c8 commit d461851
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function parse (src) {
function config (options) {
var path = '.env'
var encoding = 'utf8'
var proc = true

if (options) {
if (options.path) {
Expand All @@ -53,15 +54,20 @@ function config (options) {
if (options.encoding) {
encoding = options.encoding
}
if (options.proc) {
proc = options.proc
}
}

try {
// specifying an encoding returns a string instead of a buffer
var parsedObj = parse(fs.readFileSync(path, { encoding: encoding }))

Object.keys(parsedObj).forEach(function (key) {
process.env[key] = process.env[key] || parsedObj[key]
})
if (proc) {
Object.keys(parsedObj).forEach(function (key) {
process.env[key] = process.env[key] || parsedObj[key]
})
}

return { parsed: parsedObj }
} catch (e) {
Expand Down

0 comments on commit d461851

Please sign in to comment.