For a CI / CD pipeline I would like to replace a placeholder in my nginx.conf file with a generated map which looks like the following:
map $cookie_language $lang {
default en
en en
de de
es es
}
In the nginx.conf file there is the placeholder # REPLACE_ME_WITH_LANGUAGE_MAP
which I am replacing with the following command:
sed -i -e "s/# REPLACE_ME_WITH_LANGUAGE_MAP/$languagemap/g" ./ci/nginx.conf
Full script looks like the following:
languagemap='map $cookie_language $lang {'
firstlanguage=$(jq -r '.locales[0]' src/assets/locales.json | jq -r '.build')
languagemap="${languagemap}| default $firstlanguage"
for locale in $(jq -r '.locales[] | @base64' src/assets/locales.json); do
lang=$(echo "$locale" | base64 --decode | jq -r '.build')
languagemap="${languagemap}| $lang $lang"
npm run ci-build -- --output-path ${OUTPUT_PATH}/$lang --configuration=${ANGULAR_CONFIGURATION} --i18n-format=xlf --i18n-file=src/locale/messages.$lang.xlf --i18n-locale=$lang
done
languagemap="${languagemap}|}"
sed -i "t" "s/# REPLACE_ME_WITH_LANGUAGE_MAP/$languagemap/g" ./ci/nginx.conf
Running this always brings up:
+ sed -i tmp s/# REPLACE_ME_WITH_LANGUAGE_MAP/map $cookie_language $lang {| default en| en en| de de|}/g ./ci/nginx.conf
sed: can't find label for jump to `mp'
What's the point?