Created
January 30, 2019 13:07
-
-
Save mertenvg/f4b7695466ebccf1af3255a5bbd33e31 to your computer and use it in GitHub Desktop.
Replace all {{VAR_NAME}} tokens with their corresponding environment variable values into an `env.json` file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
APP_ROOT="${0%/*}/.." | |
APP_DIST="$APP_ROOT/build" | |
mkdir -p "$APP_DIST" | |
cp "$APP_ROOT/src/env.json.tpl" "$APP_DIST/env.json" | |
# replace all {{VAR_NAME}} tokens with their corresponding environment variable value | |
for key in `egrep -io '{{[A-Z_0-9]+}}' src/env.json.tpl | egrep -io '[A-Z_0-9]+'`; do | |
sed -i '' -e "s|{{${key}}}|${!key}|g" "$APP_DIST/env.json" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment