diff --git a/helpers/TypeScriptExtensions.ts b/helpers/TypeScriptExtensions.ts index 19954200f153ee631fd35470da2e378f1fdf227f..50c386fcc9b9c5b411580b2fbdfdf378ba5e5de9 100644 --- a/helpers/TypeScriptExtensions.ts +++ b/helpers/TypeScriptExtensions.ts @@ -8,6 +8,7 @@ declare global { toBoolean: () => boolean; capitalizingFirstLetter: () => string; capitalizeName: () => string; + convertWithEnvVars: () => string; } } @@ -17,6 +18,7 @@ function registerAll() { registerStringToBoolean(); registerStringCapitalizingFirstLetter(); registerStringCapitalizeName(); + registerStringConvertWithEnvVars(); } function registerBigIntJson() { @@ -55,6 +57,14 @@ function registerStringCapitalizeName() { }; } +function registerStringConvertWithEnvVars() { + String.prototype.convertWithEnvVars = function (this: string): string { + return this.replace(/\${?([a-zA-Z0-9_]+)}?/g, (match: string, p1: string) => { + return process.env[p1] || ''; + }); + }; +} + registerAll();