Skip to content

Commit

Permalink
skip if no var exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Pari Work Temp committed Aug 13, 2024
1 parent 5b29825 commit 7344ffd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions resources/eas-json-values.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ REPLACE_WITH_APPSTORE_CONNECT_APP_NAME=TN Bootsrapper RN
[email protected]
REPLACE_WITH_APPLESTORE_CONNECT_ID=6446805695
REPLACE_WITH_APPLE_TEAM_ID=6BNA6HFF6B
REPLACE_WITH_REVIEW_APP_SENTRY_PROJECT_NAME=tn-bootsrapper-rn

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ REPLACE_WITH_APPSTORE_CONNECT_APP_NAME=
REPLACE_WITH_APPLE_ID_EMAIL_SIGNING_APP=
REPLACE_WITH_APPLE_TEAM_ID=
REPLACE_WITH_APPLESTORE_CONNECT_ID=
REPLACE_WITH_REVIEW_APP_SENTRY_PROJECT_NAME=
17 changes: 11 additions & 6 deletions {{cookiecutter.project_slug}}/scripts/setup_mobile_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@ config_file=mobile/$1
defaults_file=resources/$2


declare -a replace_with
declare -a config_vars
declare -a merged_arr

while IFS= read -r line; do
replace_with+=("$line")
config_vars+=("$line")
done < <(grep -o "REPLACE_WITH_[A-Z_]*" "$config_file")

while IFS= read -r line; do
merged_arr+=("$line")
done < <(grep -o "REPLACE_WITH_[A-Z_]*" "$defaults_file")


for i in "${replace_with[@]}"; do
for i in "${config_vars[@]}"; do
value=$(grep -o "$i=.*" "$defaults_file")
if [[ -z $value ]]; then
echo "Skipping $i as it does not exist in $defaults_file"
continue
fi

value=${value#*=}
value=$(printf '%q' "$value")
# echo $i has value $value
if [[ -n $value ]]; then
# replace that name in the file with the value
sed -i.bak "s#<$i>#$value#g" "$config_file"
fi
else
echo "Skipping $i as it does not exist in $defaults_file"
fi
done

0 comments on commit 7344ffd

Please sign in to comment.