Created
February 6, 2019 16:51
-
-
Save christianromney/fe548ddaeb1fc7ee12657bc72ec586bd to your computer and use it in GitHub Desktop.
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 | |
if [[ $1 = "dev" ]]; then | |
echo -e "\033[1;32mUsing dev environment" | |
sed -i '' -e 's/\$DB_TST/$DB_DEV/' .envrc | |
direnv allow | |
elif [[ $1 = "test" ]]; then | |
echo -e "\033[1;33mUsing test environment" | |
sed -i '' -e 's/\$DB_DEV/$DB_TST/' .envrc | |
direnv allow | |
else | |
if [[ -z "$DATABASE_URL" ]]; then | |
echo -e "\033[1;31mEnvironment not set" | |
else | |
echo "$DATABASE_URL" | grep _dev > /dev/null | |
if [[ $? -eq 0 ]]; then | |
echo -e "\033[1;32mCurrent environment: development" | |
else | |
echo -e "\033[1;33mCurrent environment: test" | |
fi | |
fi | |
fi | |
tput sgr0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment