Skip to content

Commit 5eed9ad

Browse files
committed
fix: Stops formatting autofix from failing when files have been deleted
1 parent 21461e6 commit 5eed9ad

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/prettier.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,21 @@ jobs:
2424
| grep -E '\.(ts|tsx|js|jsx|json|md|yaml|yml|css|scss)$' || true)
2525
2626
if [ -n "$CHANGED_FILES" ]; then
27-
echo "$CHANGED_FILES" | xargs yarn prettier --write
27+
FILES_TO_FORMAT=""
28+
29+
while IFS= read -r file; do
30+
if [ -f "$file" ]; then
31+
FILES_TO_FORMAT="$FILES_TO_FORMAT\n$file"
32+
else
33+
echo "Skipping missing file: $file"
34+
fi
35+
done <<< "$CHANGED_FILES"
36+
37+
if [ -n "$FILES_TO_FORMAT" ]; then
38+
printf "%b\n" "$FILES_TO_FORMAT" | sed '/^$/d' | xargs yarn prettier --write
39+
else
40+
echo "No existing files to format"
41+
fi
2842
else
2943
echo "No files to format"
3044
fi

0 commit comments

Comments
 (0)