-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathformat_code.sh
executable file
·35 lines (29 loc) · 1.08 KB
/
format_code.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
#!/bin/bash
# Exit on first error
set -e
echo "Formatting TypeScript and React files..."
# Ensure Prettier is installed or install it
if ! [ -x "$(command -v prettier)" ]; then
echo "Prettier is not installed. Installing..."
npm install -g prettier
fi
# Format .ts and .tsx files
prettier --write "**/*.ts"
prettier --write "**/*.tsx"
echo "Formatting Python files..."
# Ensure Black is installed or install it
if ! [ -x "$(command -v black)" ]; then
echo "Black is not installed. Installing..."
pip install black
fi
# Format all Python files
black . --exclude '/GomokuEngine/external|/venv'
echo "Formatting C++ files..."
# Ensure clang-format is installed or install it
if ! [ -x "$(command -v clang-format)" ]; then
echo "clang-format is not installed. Installing..."
sudo apt-get install -y clang-format
fi
# Format all C++ files (.cpp, .hpp, .cc, .cxx)
find . \( -path './GomokuEngine/external' -prune -o -path './GomokuEngine/build' -prune \) -o -name 'pybinds.cpp' -prune -o -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -i -style=file {} +
echo "Formatting complete."