ai #1
@@ -63,6 +63,7 @@ export class Config {
|
||||
/**
|
||||
* Updates the template JSON by adding/updating params from the given environment.
|
||||
* Params are added as "!!! paramName": "@paramName@" placeholder pairs.
|
||||
* If a param's @placeholder@ already exists in template, it won't be added.
|
||||
* Existing template content is preserved.
|
||||
*/
|
||||
updateTemplateFromEnv(env: Env) {
|
||||
@@ -81,11 +82,17 @@ export class Config {
|
||||
// Add/update params from the environment as placeholders
|
||||
for (const param of env.params) {
|
||||
if (param.name && param.name.trim() !== "") {
|
||||
const placeholderKey = `!!! ${param.name}`;
|
||||
const placeholderValue = `@${param.name}@`;
|
||||
|
||||
// Check if this placeholder already exists anywhere in the template
|
||||
const placeholderAlreadyExists = this.template.content.includes(placeholderValue);
|
||||
|
||||
if (!placeholderAlreadyExists) {
|
||||
const placeholderKey = `!!! ${param.name}`;
|
||||
templateObj[placeholderKey] = placeholderValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert back to formatted JSON string
|
||||
const newTemplateContent = JSON.stringify(templateObj, null, 4);
|
||||
|
||||
Reference in New Issue
Block a user