forked from anoma/namada
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only add specified env vars to bundle (anoma#493)
- Loading branch information
Showing
5 changed files
with
42 additions
and
4 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Selects a subset of environment variables from process.env. | ||
* | ||
* @param {string} prefix - All env vars starting with this prefix are added | ||
* @param {string[]} extras - Other env vars that should be added | ||
* @returns {object} An object containing only the allowed env vars | ||
*/ | ||
const getProcessEnv = (prefix, extras) => { | ||
const prefixedEntries = Object.entries(process.env) | ||
.filter(([key, value]) => key.startsWith(`${prefix}_`)); | ||
|
||
const extraEntries = extras.map(key => [key, process.env[key]]); | ||
|
||
return prefixedEntries.concat(extraEntries).reduce( | ||
(acc, [key, value]) => ({ [key]: value, ...acc }), | ||
{} | ||
); | ||
}; | ||
|
||
module.exports = { | ||
getProcessEnv, | ||
}; |