Created
May 5, 2023 08:22
-
-
Save rajrajhans/315a847488fab72fd527ddc324bd8179 to your computer and use it in GitHub Desktop.
Script for Renaming Phoenix Project (works with Phoenix 1.7)
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
| #!/bin/bash | |
| set -e | |
| CURRENT_NAME="PhoenixStarter" | |
| CURRENT_OTP="phoenix_starter" | |
| NEW_NAME="NewName" | |
| NEW_OTP="new_name" | |
| if [[ "$OSTYPE" == "darwin"* ]]; then | |
| ack -l $CURRENT_NAME --ignore-file=is:rename_phoenix_project | xargs sed -i -e "s/$CURRENT_NAME/$NEW_NAME/g" | |
| ack -l $CURRENT_OTP --ignore-file=is:rename_phoenix_project | xargs sed -i -e "s/$CURRENT_OTP/$NEW_OTP/g" | |
| else | |
| ack -l $CURRENT_NAME --ignore-file=is:rename_phoenix_project | xargs sed -i '' -e "s/$CURRENT_NAME/$NEW_NAME/g" | |
| ack -l $CURRENT_OTP --ignore-file=is:rename_phoenix_project | xargs sed -i '' -e "s/$CURRENT_OTP/$NEW_OTP/g" | |
| fi | |
| git mv lib/$CURRENT_OTP lib/$NEW_OTP || echo "No lib/$CURRENT_OTP to rename. Skipping." | |
| git mv lib/$CURRENT_OTP.ex lib/$NEW_OTP.ex || echo "No lib/$CURRENT_OTP.ex to rename. Skipping." | |
| git mv lib/${CURRENT_OTP}_web lib/${NEW_OTP}_web || echo "No lib/${CURRENT_OTP}_web to rename. Skipping." | |
| git mv lib/${CURRENT_OTP}_web.ex lib/${NEW_OTP}_web.ex || echo "No lib/${CURRENT_OTP}_web.ex to rename. Skipping." | |
| git mv test/$CURRENT_OTP test/$NEW_OTP || echo "No test/$CURRENT_OTP to rename. Skipping." | |
| git mv test/${CURRENT_OTP}_web test/${NEW_OTP}_web || echo "No test/${CURRENT_OTP}_web to rename. Skipping." | |
| echo "Done renaming project from $CURRENT_NAME to $NEW_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment