Socket
Socket
Sign inDemoInstall

dotenv-expand

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv-expand - npm Package Compare versions

Comparing version 0.1.0 to 4.0.0

48

lib/main.js
'use strict'
function expandValue (obj, value) {
var possible = value.substring(1)
// process.env value 'wins' over .env file's value
value = process.env[possible] || obj[possible] || ''
var dotenvExpand = function (config) {
var interpolate = function (env) {
var matches = env.match(/\$([a-zA-Z0-9_]+)|\${([a-zA-Z0-9_]+)}/g) || []
return value
}
matches.forEach(function (match) {
var key = match.replace(/\$|{|}/g, '')
var expand = function (obj) {
Object.keys(obj).forEach(function (key) {
var value = obj[key]
// process.env value 'wins' over .env file's value
var variable = process.env[key] || config.parsed[key] || ''
if (value.charAt(0) === '$') {
value = expandValue(obj, value)
}
// Resolve recursive interpolations
variable = interpolate(variable)
if (value.substring(0, 2) === '\\$') {
value = value.substring(1)
env = env.replace(match, variable)
})
return env
}
for (var configKey in config.parsed) {
if (config.parsed[configKey].substring(0, 2) === '\\$') {
config.parsed[configKey] = config.parsed[configKey].substring(1)
} else {
config.parsed[configKey] = interpolate(config.parsed[configKey])
}
}
obj[key] = value
})
for (var processKey in config.parsed) {
process.env[processKey] = config.parsed[processKey]
}
Object.keys(obj).forEach(function (key) {
process.env[key] = obj[key]
})
return obj
return config
}
module.exports = expand
module.exports = dotenvExpand
{
"name": "dotenv-expand",
"version": "0.1.0",
"version": "4.0.0",
"description": "Expand environment variables using dotenv",

@@ -19,7 +19,7 @@ "main": "lib/main.js",

"devDependencies": {
"dotenv": "^2.0.0",
"lab": "^7.3.0",
"should": "^7.1.1",
"standard": "^5.4.1"
"dotenv": "^4.0.0",
"lab": "^13.0.1",
"should": "^11.2.1",
"standard": "^9.0.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc