From 6757bebf45ae03d411f6d30d668f94bbfca64a16 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Sun, 26 Feb 2023 12:15:03 +0000 Subject: [PATCH] - fix array placeholders are not correctly replaced --- src/transform.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transform.ts b/src/transform.ts index e29a103..23ea134 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -269,7 +269,7 @@ export function replaceEmptyTemplate(template: string, options: ReleaseNotesOpti } const placeholderMap = new Map() fillAdditionalPlaceholders(options, placeholderMap) - return replacePlaceholders(template, new Map(), placeholderMap, placeholders, undefined, options.configuration) + return replacePlaceholders(template, EMPTY_MAP, placeholderMap, placeholders, undefined, options.configuration) } function fillAdditionalPlaceholders( @@ -394,9 +394,9 @@ function fillArrayPlaceholders( values: string[] ): void { for (let i = 0; i < values.length; i++) { - placeholderMap.set(`\${{${key}[${i}]}}`, values[i]) + placeholderMap.set(`${key}[${i}]`, values[i]) } - placeholderMap.set(`\${{${key}[*]}}`, values.join(', ')) + placeholderMap.set(`${key}[*]`, values.join(', ')) } function fillReviewPlaceholders( @@ -407,10 +407,10 @@ function fillReviewPlaceholders( // retrieve the keys from the CommentInfo object for (const childKey of Object.keys(EMPTY_COMMENT_INFO)) { for (let i = 0; i < values.length; i++) { - placeholderMap.set(`\${{${parentKey}[${i}].${childKey}}}`, values[i][childKey as keyof CommentInfo]?.toLocaleString('en') || '') + placeholderMap.set(`${parentKey}[${i}].${childKey}`, values[i][childKey as keyof CommentInfo]?.toLocaleString('en') || '') } placeholderMap.set( - `\${{${parentKey}[*].${childKey}}}`, + `${parentKey}[*].${childKey}`, values.map(value => value[childKey as keyof CommentInfo]?.toLocaleString('en') || '').join(', ') ) }