UNPKG

@builder.io/dev-tools

Version:

Builder.io Visual CMS Devtools

23 lines (22 loc) 846 B
/** * Substitutes environment variables in a string. * Replaces ${VAR_NAME} patterns with their corresponding values from the env object. * If a variable is not found in env, the pattern is left as-is. * * @param str - The string containing environment variable patterns * @param env - A record of environment variable names to their values * @returns The string with all ${VAR_NAME} patterns replaced * * @example * substituteEnvVars("Hello ${USER}!", { USER: "Alice" }) * // Returns: "Hello Alice!" * * @example * substituteEnvVars("Path: ${HOME}/docs", { HOME: "/Users/alice" }) * // Returns: "Path: /Users/alice/docs" * * @example * substituteEnvVars("Missing: ${UNKNOWN}", {}) * // Returns: "Missing: ${UNKNOWN}" */ export declare function substituteEnvVars(str: string, env: Record<string, string | undefined>): string;