Created
January 31, 2019 22:19
-
-
Save phptek/5043582927dd60b3ee28385fe31e8aff 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
#!/bin/bash | |
# | |
# Replace Eklektos' namespaces with the one used in your project. | |
# | |
# Run the following command from the directory containing your project's "app" or "mysite" directory: | |
# | |
# $> ./namespaceify.sh 'Foo\Bar' app | |
# | |
# This will convert for example: namespace Eklektos\Eklektos\Model\FooBar into: namespace Foo\Bar\Model\FooBar | |
namespace=$( echo $1 | sed -e 's#\\#\\\\#g' ) | |
dir=$2 | |
if [ \( -z "$namespace" -o -z "$dir" \) ]; then | |
echo "Incorrect parameters passed." | |
exit 1 | |
fi | |
if [ ! -d "$dir" ]; then | |
echo "Couldn't find directory: $dir" | |
exit 1 | |
fi | |
for file in $( find "$dir" -type f | xargs grep -l 'Eklektos' ) | |
do | |
sed -i -e "s#Eklektos\\\Eklektos#$namespace#g" $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment