-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·74 lines (64 loc) · 1.79 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
# Argument = -n namespace -p plugin
REPLACENAMESPACE="{{PLUGIN_NAMESPACE}}"
REPLACENAME="{{PLUGIN_NAME}}"
REPLACEDISPLAYNAME="{{PLUGIN_DISPLAY_NAME}}"
REPLACEDESCRIPTION="{{PLUGIN_DESCRIPTION}}"
REPLACEURI="{{PLUGIN_URI}}"
usage()
{
cat << EOF
usage: $0 options
OPTIONS:
-h Show this message
-n The namespace of the plugin
-p The name of the plugin
EOF
}
NAMESPACE=
NAME=
DISPLAYNAME=
DESCRIPTION=
URI=
while getopts "hn:p:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
n)
NAMESPACE=$OPTARG
;;
p)
NAME=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $NAMESPACE ]] || [[ -z $NAME ]]
then
usage
exit 1
fi
# Rename all directories and files
find . -depth -name '*{{PLUGIN_NAMESPACE}}*' -execdir bash -c 'mv -i "$1" "${1/$2/$3}"' bash {} $REPLACENAMESPACE $NAMESPACE \;
find . -depth -name '*{{PLUGIN_NAME}}*' -execdir bash -c 'mv -i $1 ${1/$2/$3}' bash {} $REPLACENAME $NAME \;
# # Rename all instances inside of files.
find . -depth -type f \( -name "*.php" -o -name "*.xml" \) -execdir sed -i "" "s/$REPLACENAMESPACE/$NAMESPACE/g" {} \;
find . -depth -type f \( -name "*.php" -o -name "*.xml" \) -execdir sed -i "" "s/$REPLACENAME/$NAME/g" {} \;
if [[ -n $DISPLAYNAME ]]
then
find . -depth -type f \( -name "*.php" -o -name "*.xml" \) -execdir sed -i "" "s/$REPLACEDISPLAYNAME/$DISPLAYNAME/g" {} \;
fi
if [[ -n $DESCRIPTION ]]
then
find . -depth -type f \( -name "*.php" -o -name "*.xml" \) -execdir sed -i "" "s/$REPLACEDESCRIPTION/$DESCRIPTION/g" {} \;
fi
if [[ -n $URI ]]
then
find . -depth -type f \( -name "*.php" -o -name "*.xml" \) -execdir sed -i "" "s/$REPLACEURI/$URI/g" {} \;
fi