commit
This commit is contained in:
parent
68f4b60012
commit
41ae7ff4bd
1010 changed files with 38622 additions and 17071 deletions
27
node_modules/dotenv/lib/main.js
generated
vendored
27
node_modules/dotenv/lib/main.js
generated
vendored
|
@ -58,7 +58,7 @@ function _parseVault (options) {
|
|||
|
||||
// handle scenario for comma separated keys - for use with key rotation
|
||||
// example: DOTENV_KEY="dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenv.org/vault/.env.vault?environment=prod"
|
||||
const keys = _dotenvKey().split(',')
|
||||
const keys = _dotenvKey(options).split(',')
|
||||
const length = keys.length
|
||||
|
||||
let decrypted
|
||||
|
@ -99,11 +99,18 @@ function _debug (message) {
|
|||
console.log(`[dotenv@${version}][DEBUG] ${message}`)
|
||||
}
|
||||
|
||||
function _dotenvKey () {
|
||||
function _dotenvKey (options) {
|
||||
// prioritize developer directly setting options.DOTENV_KEY
|
||||
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
||||
return options.DOTENV_KEY
|
||||
}
|
||||
|
||||
// secondary infra already contains a DOTENV_KEY environment variable
|
||||
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
||||
return process.env.DOTENV_KEY
|
||||
}
|
||||
|
||||
// fallback to empty string
|
||||
return ''
|
||||
}
|
||||
|
||||
|
@ -162,7 +169,12 @@ function _configVault (options) {
|
|||
|
||||
const parsed = DotenvModule._parseVault(options)
|
||||
|
||||
DotenvModule.populate(process.env, parsed, options)
|
||||
let processEnv = process.env
|
||||
if (options && options.processEnv != null) {
|
||||
processEnv = options.processEnv
|
||||
}
|
||||
|
||||
DotenvModule.populate(processEnv, parsed, options)
|
||||
|
||||
return { parsed }
|
||||
}
|
||||
|
@ -185,7 +197,12 @@ 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 && options.processEnv != null) {
|
||||
processEnv = options.processEnv
|
||||
}
|
||||
|
||||
DotenvModule.populate(processEnv, parsed, options)
|
||||
|
||||
return { parsed }
|
||||
} catch (e) {
|
||||
|
@ -202,7 +219,7 @@ function config (options) {
|
|||
const vaultPath = _vaultPath(options)
|
||||
|
||||
// fallback to original dotenv if DOTENV_KEY is not set
|
||||
if (_dotenvKey().length === 0) {
|
||||
if (_dotenvKey(options).length === 0) {
|
||||
return DotenvModule.configDotenv(options)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue