Skip to content

Commit

Permalink
Add ability to change the target from process.env to your own object
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Jun 15, 2023
1 parent 75cee88 commit 96c29b4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ function _configVault (options) {

const parsed = DotenvModule._parseVault(options)

DotenvModule.populate(process.env, parsed, options)
let processEnv = process.env
if (options) {
if (options.processEnv != null) {
processEnv = options.processEnv
}
}

DotenvModule.populate(processEnv, parsed, options)

return { parsed }
}
Expand All @@ -185,7 +192,14 @@ function configDotenv (options) {
// Specifying an encoding returns a string instead of a buffer
const parsed = DotenvModule.parse(fs.readFileSync(dotenvPath, { encoding }))

DotenvModule.populate(process.env, parsed, options)
let processEnv = process.env
if (options) {
if (options.processEnv != null) {
processEnv = options.processEnv
}
}

DotenvModule.populate(processEnv, parsed, options)

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

0 comments on commit 96c29b4

Please sign in to comment.