-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_code.sh
More file actions
30 lines (27 loc) · 848 Bytes
/
format_code.sh
File metadata and controls
30 lines (27 loc) · 848 Bytes
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
#!/bin/bash
# Function to run Maven formatting in modules
run_maven_format() {
echo "Running Spotless on $1..."
cd "$1" || exit
mvn spotless:apply
cd - > /dev/null || exit
}
# Detect the operating system
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then
echo "Detected Linux/macOS"
run_maven_format "modules/shorturl-api"
run_maven_format "modules/shorturl-common"
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
echo "Detected Windows - Running PowerShell script..."
pwsh -Command "& {
Set-Location -Path 'modules/shorturl-api'
mvn spotless:apply
Set-Location -Path '../..'
Set-Location -Path 'modules/shorturl-common'
mvn spotless:apply
Set-Location -Path '../..'
}"
else
echo "Unsupported OS"
exit 1
fi