From 67088b1fe46fe474aee47599f1b84a110c33365d Mon Sep 17 00:00:00 2001 From: HaseenaSainul <41037131+HaseenaSainul@users.noreply.github.com> Date: Thu, 7 Mar 2024 13:27:10 +0530 Subject: [PATCH] CPPSDK: update install script to handle version parsing for file based and prebuild install cases (#173) --- languages/cpp/templates/sdk/scripts/install.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/languages/cpp/templates/sdk/scripts/install.sh b/languages/cpp/templates/sdk/scripts/install.sh index b1aa8892..b31556a2 100755 --- a/languages/cpp/templates/sdk/scripts/install.sh +++ b/languages/cpp/templates/sdk/scripts/install.sh @@ -26,9 +26,16 @@ done GetVersion() { PackagePath=${SdkPath}/../../../../../../package-lock.json - InputKey="name\": \"@firebolt-js/openrpc" - LineNo="$(grep -n "${InputKey}" ${PackagePath} | head -n 1 | cut -d: -f1)" - VersionLine=$((LineNo++)) + InputKey="\"@firebolt-js/openrpc\":" + Line=$(grep -n "${InputKey}" ${PackagePath}) + if [[ "${Line}" == *"file:"* ]]; then + InputKey="name\": \"@firebolt-js/openrpc" + Line=$(grep -n "${InputKey}" ${PackagePath}) + LineNo="$(echo ${Line} | head -n 1 | cut -d: -f1)" + VersionLine=$((LineNo++)) + else + LineNo="$(echo ${Line} | head -n 1 | cut -d: -f1)" + fi eval "array=(`sed -n "${LineNo}p" < ${PackagePath} | sed 's/\"/\n/g'`)" Version=${array[2]} }