From 2f4583b8929b694eaee20bdc7c1e9cc4ea77e470 Mon Sep 17 00:00:00 2001 From: sharma-shreyas Date: Tue, 24 Sep 2024 14:21:45 +0530 Subject: [PATCH] update dist file --- dist/index.js | 73 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index e684f9b..5a16acb 100644 --- a/dist/index.js +++ b/dist/index.js @@ -34803,23 +34803,66 @@ ${content}`; CI_COMMIT_SHA, "getAssetName" ); - var matches = regExp.exec(fileContents); + const startRegex = + /{{\s*config\s*\(/im; + const startMatch = fileContents.match(startRegex); + let configSection = '' + if (startMatch) { + const startIndex = startMatch.index; + const openParensIndex = fileContents.indexOf('(', startIndex) + 1; + let openParensCount = 1; + let endIndex = openParensIndex; + + while (openParensCount > 0 && endIndex < fileContents.length) { + const char = fileContents[endIndex]; + + if (char === '(') { + openParensCount++; + } else if (char === ')') { + openParensCount--; + } + endIndex++; + } + + const endMarker = '}}'; + const finalEndIndex = fileContents.indexOf(endMarker, endIndex) + endMarker.length; - logger_logger.withInfo( - "Successfully executed regex matching", - gitlab_integration_integrationName, - CI_COMMIT_SHA, - "getAssetName" - ); + configSection = fileContents.substring(startIndex, finalEndIndex); + logger_logger.withInfo( + "Extracted config section", + gitlab_integration_integrationName, + CI_COMMIT_SHA, + "getAssetName" + ); - if (matches) { - logger_logger.withInfo( - `Found a match: ${matches[1].trim()}`, - gitlab_integration_integrationName, - CI_COMMIT_SHA, - "getAssetName" - ); - return matches[1].trim(); + if (configSection){ + logger_logger.withInfo( + "Executing final regex", + gitlab_integration_integrationName, + CI_COMMIT_SHA, + "getAssetName" + ); + + var matches = regExp.exec(configSection); + + logger_logger.withInfo( + "Successfully executed regex matching", + gitlab_integration_integrationName, + CI_COMMIT_SHA, + "getAssetName" + ); + + } + if (matches) { + logger_logger.withInfo( + `Found a match: ${matches[1].trim()}`, + gitlab_integration_integrationName, + CI_COMMIT_SHA, + "getAssetName" + ); + + return matches[1].trim(); + } } }