Created
April 17, 2021 13:52
-
-
Save edymerchk/92823c5cd395694508fe94e407d54389 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -eo pipefail | |
APP_NAME="${1}" | |
MODULE_NAME="${2}" | |
FIND_APP_NAME="old" | |
FIND_MODULE_NAME="Old" | |
FIND_FRAMEWORK="rails" | |
if [ -z "${APP_NAME}" ] || [ -z "${MODULE_NAME}" ]; then | |
echo "You must supply both an app and module name, example: ${0} myapp MyApp" | |
exit 1 | |
fi | |
if [ "${APP_NAME}" = "${FIND_APP_NAME}" ]; then | |
echo "Your new app name must be different than the current app name" | |
exit 1 | |
fi | |
# ----------------------------------------------------------------------------- | |
# Script for renaming | |
# ----------------------------------------------------------------------------- | |
find . -type f -exec \ | |
perl -i -pe "s/(${FIND_APP_NAME}${FIND_FRAMEWORK}|${FIND_APP_NAME})/${APP_NAME}/g" {} + \ | |
&& find . -type f -exec \ | |
perl -i -pe "s/${FIND_MODULE_NAME}/${MODULE_NAME}/g" {} + | |
# ----------------------------------------------------------------------------- | |
cat << EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment