mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[formatters] Use pushd/popd so formatters can be called from any directory
This commit is contained in:
parent
9ffe3579d7
commit
ca45046ae3
12
.github/workflows/format-check-new.yml
vendored
12
.github/workflows/format-check-new.yml
vendored
@ -42,12 +42,24 @@ jobs:
|
||||
distribution: 'zulu'
|
||||
java-version: "16"
|
||||
|
||||
- name: Install Haxe
|
||||
uses: krdlab/setup-haxe@v1
|
||||
with:
|
||||
haxe-version: '4.3.2'
|
||||
- run: haxelib install formatter
|
||||
|
||||
- name: Install Dart
|
||||
uses: dart-lang/setup-dart@v1
|
||||
with:
|
||||
sdk: 'stable'
|
||||
|
||||
- name: Format
|
||||
run: |
|
||||
export CLANGFORMAT=`pwd`/clang/bin/clang-format
|
||||
./formatters/format-cpp.sh
|
||||
./formatters/format-csharp.sh
|
||||
./formatters/format-dart.sh
|
||||
./formatters/format-haxe.sh
|
||||
./formatters/format-java.sh
|
||||
./formatters/format-ts.sh
|
||||
git diff
|
||||
|
||||
@ -6,8 +6,12 @@ echo "Formatting C/C++ files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
if [ ! -f "$dir/.clang-format" ]; then
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
if [ ! -f ".clang-format" ]; then
|
||||
echo "Error: .clang-format not found in formatters directory"
|
||||
popd > /dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -95,7 +99,7 @@ for file in "${files[@]}"; do
|
||||
fi
|
||||
|
||||
# Format the file and capture any errors
|
||||
if ! clang-format -i -style=file:"$dir/.clang-format" "$file" 2>/dev/null; then
|
||||
if ! clang-format -i -style=file:".clang-format" "$file" 2>/dev/null; then
|
||||
printf "\nError formatting: $file\n"
|
||||
errors=$((errors + 1))
|
||||
fi
|
||||
@ -109,3 +113,6 @@ if [ $errors -gt 0 ]; then
|
||||
fi
|
||||
|
||||
echo "C/C++ formatting complete"
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
@ -7,34 +7,42 @@ echo "Formatting C# files..."
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
if command -v dotnet &> /dev/null; then
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
# Copy .editorconfig to C# directories
|
||||
cp .editorconfig ../spine-csharp/ 2>/dev/null || true
|
||||
cp .editorconfig ../spine-monogame/ 2>/dev/null || true
|
||||
cp .editorconfig ../spine-unity/ 2>/dev/null || true
|
||||
|
||||
# Format spine-csharp
|
||||
cd ../spine-csharp && dotnet format spine-csharp.csproj || echo "Warning: Some issues with spine-csharp formatting"
|
||||
cd ../formatters
|
||||
pushd ../spine-csharp > /dev/null
|
||||
dotnet format spine-csharp.csproj || echo "Warning: Some issues with spine-csharp formatting"
|
||||
popd > /dev/null
|
||||
|
||||
# Format spine-monogame
|
||||
cd ../spine-monogame && dotnet format --no-restore || echo "Warning: Some issues with spine-monogame formatting"
|
||||
cd ../formatters
|
||||
pushd ../spine-monogame > /dev/null
|
||||
dotnet format --no-restore || echo "Warning: Some issues with spine-monogame formatting"
|
||||
popd > /dev/null
|
||||
|
||||
# Format spine-unity - look for .cs files directly
|
||||
if [ -d ../spine-unity ]; then
|
||||
echo "Formatting spine-unity C# files directly..."
|
||||
cd ../spine-unity
|
||||
pushd ../spine-unity > /dev/null
|
||||
# Find all .cs files and format them using dotnet format whitespace
|
||||
find . -name "*.cs" -type f -not -path "./Library/*" -not -path "./Temp/*" -not -path "./obj/*" -not -path "./bin/*" | while read -r file; do
|
||||
dotnet format whitespace --include "$file" --no-restore 2>/dev/null || true
|
||||
done
|
||||
cd ../formatters
|
||||
popd > /dev/null
|
||||
fi
|
||||
|
||||
# Clean up .editorconfig files
|
||||
rm -f ../spine-csharp/.editorconfig
|
||||
rm -f ../spine-monogame/.editorconfig
|
||||
rm -f ../spine-unity/.editorconfig
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
else
|
||||
echo "Warning: dotnet not found. Skipping C# formatting."
|
||||
fi
|
||||
@ -4,6 +4,11 @@ set -e
|
||||
# Format Dart files
|
||||
echo "Formatting Dart files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
if command -v dart &> /dev/null; then
|
||||
find .. -name "*.dart" \
|
||||
-not -path "*/.*" \
|
||||
@ -13,3 +18,6 @@ if command -v dart &> /dev/null; then
|
||||
else
|
||||
echo "Warning: dart not found. Skipping Dart formatting."
|
||||
fi
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
@ -4,6 +4,11 @@ set -e
|
||||
# Format Haxe files
|
||||
echo "Formatting Haxe files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
if command -v haxelib &> /dev/null && haxelib list formatter &> /dev/null; then
|
||||
# Format spine-haxe directory
|
||||
if [ -d ../spine-haxe ]; then
|
||||
@ -12,3 +17,6 @@ if command -v haxelib &> /dev/null && haxelib list formatter &> /dev/null; then
|
||||
else
|
||||
echo "Warning: haxe formatter not found. Install with: haxelib install formatter"
|
||||
fi
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
@ -6,4 +6,11 @@ echo "Formatting Java files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
./formatters/gradlew -p formatters spotlessJavaApply --quiet
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
# Run gradle from the formatters directory
|
||||
./gradlew spotlessJavaApply --quiet
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
@ -4,6 +4,11 @@ set -e
|
||||
# Format Swift files
|
||||
echo "Formatting Swift files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
if command -v swift-format &> /dev/null; then
|
||||
find .. -name "*.swift" \
|
||||
-not -path "*/.*" \
|
||||
@ -13,3 +18,6 @@ if command -v swift-format &> /dev/null; then
|
||||
else
|
||||
echo "Warning: swift-format not found. Install from https://github.com/apple/swift-format"
|
||||
fi
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
@ -6,13 +6,25 @@ echo "Formatting TypeScript files..."
|
||||
|
||||
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
# Store original directory
|
||||
pushd "$dir" > /dev/null
|
||||
|
||||
# Check if tsfmt.json files match
|
||||
if ! cmp -s ../spine-ts/tsfmt.json ../tests/tsfmt.json; then
|
||||
echo -e "\033[1;31mERROR: spine-ts/tsfmt.json and tests/tsfmt.json differ!\033[0m"
|
||||
echo -e "\033[1;31mPlease sync them to ensure consistent formatting.\033[0m"
|
||||
popd > /dev/null
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Format TypeScript files
|
||||
cd ../spine-ts && npm run format && cd ../formatters
|
||||
cd ../tests && npm run format -r && cd ../formatters
|
||||
pushd ../spine-ts > /dev/null
|
||||
npm run format
|
||||
popd > /dev/null
|
||||
|
||||
pushd ../tests > /dev/null
|
||||
npm run format -r
|
||||
popd > /dev/null
|
||||
|
||||
# Return to original directory
|
||||
popd > /dev/null
|
||||
Loading…
x
Reference in New Issue
Block a user