-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-overlays-argument.sh
executable file
·57 lines (51 loc) · 1.58 KB
/
start-overlays-argument.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
#!/bin/bash
# List of project directories
PROJECTS=(
"game-info"
"missions"
"youtube-stats"
)
# Function to install dependencies and start the server
run_project() {
local PROJECT=$1
echo "----------------------------------------"
echo "Processing: $PROJECT"
# Install dependencies if package.json exists
if [ -f "$PROJECT/package.json" ]; then
(cd "$PROJECT" && npm install)
if [ $? -ne 0 ]; then
echo "Failed to install dependencies for $PROJECT."
return 1
fi
echo "Dependencies installed for $PROJECT."
else
echo "No package.json found in $PROJECT. Skipping dependencies."
fi
# Start server.js if it exists
local SERVER_FILE="$PROJECT/server.js"
if [ -f "$SERVER_FILE" ]; then
(cd "$PROJECT" && node server.js &)
echo "Server started for $PROJECT."
else
echo "No server.js found in $PROJECT. Skipping server start."
fi
}
# Run a specific project or all projects
if [ $# -eq 1 ]; then
# Run the project corresponding to the argument
CHOICE=$1
if [[ "$CHOICE" -ge 1 && "$CHOICE" -le "${#PROJECTS[@]}" ]]; then
run_project "${PROJECTS[$((CHOICE-1))]}"
else
echo "Invalid choice. Enter a number between 1 and ${#PROJECTS[@]}."
exit 1
fi
else
# Run all projects if no argument is provided
echo "No specific project selected. Running all projects..."
for PROJECT in "${PROJECTS[@]}"; do
run_project "$PROJECT"
done
fi
echo "----------------------------------------"
echo "All tasks completed!"