MCPcopy
hub / github.com/toddbluhm/env-cmd / expandEnvs

Function expandEnvs

src/expand-envs.ts:7–12  ·  view source on GitHub ↗
(str: string, envs: Environment)

Source from the content-addressed store, hash-verified

5 * if the environment variable doesn't exist, it leaves it as is.
6*/
7export 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}

Callers 2

EnvCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected