forked from dimosp/CineFriends
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-app.sh
70 lines (63 loc) · 2.6 KB
/
run-app.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
#!/bin/bash
################################################################################
# Help #
################################################################################
Help()
{
# Display Help
echo "This script starts the backend and frontend of our application."
echo "You need to have npm installed for this script."
echo
echo "Usage: ./run-app.sh [-h|p]"
echo "Options:"
echo "h Print this Help."
echo "p Give the path to the root directory of the project."
echo
echo "Examples: 1) ./run-app -p ~/Documents/CineFriends"
echo " 2) ./run-app -p ."
echo
}
################################################################################
################################################################################
# Main program #
################################################################################
################################################################################
# Process the input options. #
################################################################################
# Get the options
while getopts ":hp:" option; do
case $option in
h) # display Help
Help
exit;;
p) # give the path to the root directory
backend_path="${2}/backend"
frontend_package_path="${2}/frontend"
frontend_app_path="${2}/frontend/src"
# Install backend dependencies (this migth take a few minutes)
cd $backend_path
npm install # comment this line if you have everything installed
# Run Node.js server in backend
# Accesible from http://localhost:8080/api/
npm run dev &
# This trailing ampersand directs the shell to run the command in the background,
# that is, it is forked and run in a separate sub-shell, as a job, asynchronously.
# The shell will immediately return the return status of 0 for true and continue
# as normal, either processing further commands in a script or returning the cursor
# focus back to the user in a Linux terminal.
# Install frontend dependencies (this migth take a few minutes)
cd ..
cd $frontend_package_path
npm install & # comment this line if you have everything installed
# Run React.js app
# Accesible from http://localhost:3000
cd ..
cd $frontend_app_path
npm start
exit;;
\?) # incorrect option
echo "Error: Invalid option"
exit;;
esac
done
Help