-
-
Notifications
You must be signed in to change notification settings - Fork 862
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
24 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ function _parseVault (options) { | |
|
||
// handle scenario for comma separated keys - for use with key rotation | ||
// example: DOTENV_KEY="dotenv://:[email protected]/vault/.env.vault?environment=prod,dotenv://:[email protected]/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 '' | ||
} | ||
|
||
|
@@ -212,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) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters