-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcomponent-generator
executable file
·49 lines (38 loc) · 1.33 KB
/
component-generator
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
#!/bin/bash
uppercase=$1
kebabcase="$(echo ${uppercase} | sed -e 's/\([A-Z]\)/\-\1/g' -e 's/\-//' | tr '[:upper:]' '[:lower:]')"
echo "creating folder"
cp -R .template/api components/$kebabcase
cp -R .template/test tests/api/$kebabcase
echo "modifying files for api"
cd ./components/$kebabcase
for file in $(find . -maxdepth 1 -name "*(qq)*" -type f)
do
#change variable inside file
sed -i 's/(QQ)/'$uppercase'/g' "$file"
sed -i 's/(qq)/'$kebabcase'/g' "$file"
echo ' change' "$file" 'to' `echo "${file//(qq)/$kebabcase}"`
mv "$file" `echo "${file//(qq)/$kebabcase}"`
done
# for D in $(find . -depth -name "*(qq)*" -type d) '.'
# do
# pushd $D >> /dev/null
# echo 'directory: ' "$D"
# for file in $(find . -maxdepth 1 -name "*(qq)*" -type f)
# do
# #change variable inside file
# sed -i 's/(QQ)/'$uppercase'/g' "$file"
# sed -i 's/(qq)/'$kebabcase'/g' "$file"
# echo ' change' "$file" 'to' `echo "${file//(qq)/$kebabcase}"`
# mv "$file" `echo "${file//(qq)/$kebabcase}"`
# done
# popd >> /dev/null
# echo 'change' "$D" 'to' `echo "$D"`
# #change only the last occurence of (qq)
# mv "$D" `echo "$D"`
# done
ls -al .
echo "modifying files for test"
cd ../../tests/api/$kebabcase
sed -i 's/(qq)/'$kebabcase'/g' "index.js"
echo "process complete"