env.ts

 1/**
 2 * Expand `$VAR` and `${VAR}` references to their environment variable values.
 3 * Returns the string unchanged if it contains no references.
 4 */
 5export function expandEnvVars(value: string): string {
 6  return value.replace(/\$\{([^}]+)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_, braced, bare) => {
 7    const name = braced ?? bare;
 8    return process.env[name] ?? "";
 9  });
10}