Skip to content
Snippets Groups Projects
Commit a026c4af authored by michael.minelli's avatar michael.minelli
Browse files

TypeScriptExtensions => Add function to replace env vars in str

parent bfca2c40
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment