MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / expandEnvString

Function expandEnvString

src/utils/env-expand.ts:20–27  ·  view source on GitHub ↗
(s: string, env: NodeJS.ProcessEnv = process.env)

Source from the content-addressed store, hash-verified

18 * to prevent the bug from silently regressing during refactors.
19 */
20export function expandEnvString(s: string, env: NodeJS.ProcessEnv = process.env): string {
21 if (typeof s !== 'string') return s;
22 return s
23 .replace(/\$\$/g, '\u0000DOLLAR\u0000') // escape $$ temporarily
24 .replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => env[name] ?? '')
25 .replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g, (_, name) => env[name] ?? '')
26 .replace(/\u0000DOLLAR\u0000/g, '$');
27}
28
29/** Apply expandEnvString to every value in a string-keyed map. */
30export function expandEnvObject(

Callers 2

expandEnvObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected