-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-react.sh
executable file
·53 lines (46 loc) · 1.02 KB
/
check-react.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
#!/bin/bash
package='create-react-app'
response='n'
project_name=''
error_react_not_found() {
echo -e "\n"
echo -e "\e[1;31m[ ERROR ]\e[m React app not found. Check: https://github.com/mark-doblefilo/react-app-docker"
echo -e "\n"
ask_create_react
}
main() {
if [ -d "src" ]; then
echo -e "\e[1;32m[ OK ]\e[m React app found. "
npm start
else
error_react_not_found
fi
}
ask_create_react() {
read -r -p "Do you want to create a React App? [y/N] " response
if [[ $response == "y" || $response == "Y" || $response == "yes" || $response == "Yes" ]]
then
check_package
else
exit 1
fi
}
check_package() {
if [ `npm list -g | grep -c $package` == 0 ]; then
echo -e "[1;31m[ ERROR ]\e[m create-react-app not found. "
exit 1
else
echo -e "\e[1;32m[ OK ]\e[m create-react-app package found. "
create_react_app
fi
}
create_react_app() {
read -r -p "Name for your project: " project_name
if [ -z "$project_name" ]; then
echo -e "NOPE"
exit 1
else
eval `npx create-react-app $project_name`
fi
}
main