Expand ${VAR} and $VAR references in a string using process.env.
(value: string)
| 36 | |
| 37 | /** Expand ${VAR} and $VAR references in a string using process.env. */ |
| 38 | function expandEnv(value: string): string { |
| 39 | return value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_, braced, bare) => { |
| 40 | const name = braced ?? bare |
| 41 | return process.env[name] ?? "" |
| 42 | }) |
| 43 | } |
| 44 | |
| 45 | function isPlainObject(value: unknown): value is Record<string, unknown> { |
| 46 | return typeof value === "object" && value !== null && !Array.isArray(value) |
no outgoing calls
no test coverage detected