-
-
Save itcherry/0ed5ba7a2035e354e58a89f57a02e03f to your computer and use it in GitHub Desktop.
React environment variables generator from local gradle.properties file
This file contains 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
#!/bin/bash | |
PROPERTY_FILE=~/.gradle/gradle.properties | |
function getProperty { | |
PROP_KEY=$1 | |
PROP_VALUE=`cat $PROPERTY_FILE | grep -w "$PROP_KEY" | cut -d'=' -f2` | |
echo $PROP_VALUE | |
} | |
if [ $1 == 'stage' ] | |
then | |
read -d '' env << EOF | |
API_BASE=/new/api | |
SOME_YOUR_KEY=$(getProperty "YOUR_KEY_STAGE") | |
# Insert your others key here as well | |
EOF | |
elif [ $1 == 'prod' ] | |
then | |
read -d '' env << EOF | |
API_BASE=/new/api | |
SOME_YOUR_KEY=$(getProperty "YOUR_KEY_PROD") | |
EOF | |
fi | |
echo "$env" > ../../../RELATIVE_PATH_TO_REACT_NATIVE_PROJECT/.env |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment