Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't override falsy values in process.env #17

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var dotenvExpand = function (config) {
var key = match.replace(/\$|{|}/g, '')

// process.env value 'wins' over .env file's value
var variable = process.env[key] || config.parsed[key] || ''
var variable = process.env.hasOwnProperty(key) ? process.env[key] : (config.parsed[key] || '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the two lines you updated be abstracted into a method given the similarities between the two?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, this is not code refactoring PR. it just fixing an issue.
you can make you own fork and make some additional changes, but it looks like there no chance to merge it.


// Resolve recursive interpolations
variable = interpolate(variable)
Expand All @@ -20,7 +20,7 @@ var dotenvExpand = function (config) {
}

for (var configKey in config.parsed) {
var value = process.env[configKey] || config.parsed[configKey]
var value = process.env.hasOwnProperty(configKey) ? process.env[configKey] : config.parsed[configKey]

if (config.parsed[configKey].substring(0, 2) === '\\$') {
config.parsed[configKey] = value.substring(1)
Expand Down