-
Notifications
You must be signed in to change notification settings - Fork 0
/
postbuild.sh
executable file
·38 lines (31 loc) · 1.38 KB
/
postbuild.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
#!/bin/bash
# The purpose of this script is to make changes into files generated by
# 'yarn create react-app' after 'build' is run.
helpFunction()
{
echo ""
echo "Usage: $0 -f folder_name"
echo -e "\t-f Folder name"
exit 1 # Exit script after printing help
}
while getopts "f:s:t:" opt
do
case "$opt" in
f ) folder_name="$OPTARG" ;;
? ) helpFunction ;; # Print help function in case parameter is non-existent
esac
done
if [ -z "$folder_name" ]
then
echo "Some or all of the parameters are empty";
helpFunction
fi
echo "Create application folder: $folder_name"
mkdir -p $folder_name
cp -rf build/* $folder_name
find $folder_name"/index.html" -type f | xargs sed -i "s/\/static\/js/{{ STATIC_URL }}$folder_name\/static\/js/g"
find $folder_name"/index.html" -type f | xargs sed -i "s/\/static\/css/{{ STATIC_URL }}$folder_name\/static\/css/g"
find $folder_name"/index.html" -type f | xargs sed -i "s/images\/favicons/{{ STATIC_URL }}$folder_name\/images\/favicons/g"
find $folder_name"/index.html" -type f | xargs sed -i "s/http:\/\/localhost:3000\/images/http:\/\/obahia.dea.ufv.br\/static\/$folder_name\/images/g"
# find "$folder_name/static/js/" -name "*.js" -type f -exec sed -i "s/static\/media/static\/$folder_name\/static\/media/g" {} \;
# find "$folder_name/static/js/" -name "*.map" -type f -exec sed -i "s/static\/media/static\/$folder_name\/static\/media/g" {} \;