(
templatedYaml: string,
data: { [key: string]: string },
)
| 97 | } |
| 98 | |
| 99 | export function fillTemplateVariables( |
| 100 | templatedYaml: string, |
| 101 | data: { [key: string]: string }, |
| 102 | ): string { |
| 103 | // Defensive guard against undefined/null/non-string values |
| 104 | if (!templatedYaml || typeof templatedYaml !== "string") { |
| 105 | return ""; |
| 106 | } |
| 107 | |
| 108 | return templatedYaml.replace(TEMPLATE_VAR_REGEX, (match, variableName) => { |
| 109 | // Inject data |
| 110 | if (variableName in data) { |
| 111 | return data[variableName]; |
| 112 | } |
| 113 | // If variable doesn't exist, return the original expression |
| 114 | return match; |
| 115 | }); |
| 116 | } |
| 117 | |
| 118 | export interface TemplateData { |
| 119 | inputs: Record<string, string> | undefined; |
no test coverage detected