(str: string, envs: Environment)
| 5 | * if the environment variable doesn't exist, it leaves it as is. |
| 6 | */ |
| 7 | export function expandEnvs (str: string, envs: Environment): string { |
| 8 | return str.replace(/(?<!\\)\$(\{\w+\}|\w+)?/g, (varName) => { |
| 9 | const varValue = envs[varName.startsWith('${') ? varName.slice(2, varName.length - 1) : varName.slice(1)] |
| 10 | return varValue ?? varName |
| 11 | }) |
| 12 | } |
no outgoing calls
no test coverage detected