Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dotenv

Package Overview
Dependencies
Maintainers
4
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv - npm Package Compare versions

Comparing version 16.4.4 to 16.4.5

8

CHANGELOG.md

@@ -5,4 +5,10 @@ # Changelog

## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.4.4...master)
## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.4.5...master)
## [16.4.5](https://github.com/motdotla/dotenv/compare/v16.4.4...v16.4.5) (2024-02-19)
### Changed
- 🐞 fix recent regression when using `path` option. return to historical behavior: do not attempt to auto find `.env` if `path` set. (regression was introduced in `16.4.3`) [#814](https://github.com/motdotla/dotenv/pull/814)
## [16.4.4](https://github.com/motdotla/dotenv/compare/v16.4.3...v16.4.4) (2024-02-13)

@@ -9,0 +15,0 @@

58

lib/main.js

@@ -218,48 +218,44 @@ const fs = require('fs')

let optionPathsThatExist = []
let optionPaths = [dotenvPath] // default, look for .env
if (options && options.path) {
if (!Array.isArray(options.path)) {
if (fs.existsSync(options.path)) {
optionPathsThatExist = [_resolveHome(options.path)]
}
optionPaths = [_resolveHome(options.path)]
} else {
optionPaths = [] // reset default
for (const filepath of options.path) {
if (fs.existsSync(filepath)) {
optionPathsThatExist.push(_resolveHome(filepath))
}
optionPaths.push(_resolveHome(filepath))
}
}
if (!optionPathsThatExist.length) {
optionPathsThatExist = [dotenvPath]
}
}
// If we have options.path, and it had valid paths, use them. Else fall back to .env
const pathsToProcess = optionPathsThatExist.length ? optionPathsThatExist : [dotenvPath]
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
// parsed data, we will combine it with process.env (or options.processEnv if provided).
const parsed = {}
try {
for (const path of pathsToProcess) {
let lastError
const parsedAll = {}
for (const path of optionPaths) {
try {
// Specifying an encoding returns a string instead of a buffer
const singleFileParsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
DotenvModule.populate(parsed, singleFileParsed, options)
}
const parsed = DotenvModule.parse(fs.readFileSync(path, { encoding }))
let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
DotenvModule.populate(parsedAll, parsed, options)
} catch (e) {
if (debug) {
_debug(`Failed to load ${path} ${e.message}`)
}
lastError = e
}
}
DotenvModule.populate(processEnv, parsed, options)
} catch (e) {
if (debug) {
_debug(`Failed to load ${pathsToProcess} ${e.message}`)
}
return { error: e }
let processEnv = process.env
if (options && options.processEnv != null) {
processEnv = options.processEnv
}
return { parsed }
DotenvModule.populate(processEnv, parsedAll, options)
if (lastError) {
return { parsed: parsedAll, error: lastError }
} else {
return { parsed: parsedAll }
}
}

@@ -266,0 +262,0 @@

{
"name": "dotenv",
"version": "16.4.4",
"version": "16.4.5",
"description": "Loads environment variables from .env file",

@@ -5,0 +5,0 @@ "main": "lib/main.js",

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