Skip to content

Commit 0366fb2

Browse files
committed
🔨 Improve format command with comprehensive file processing
Replace conditional stylua check with direct formatting and add file maintenance operations - Remove stylua check logic and directly format all Lua files - Add file ending fixes for Lua and Markdown files to ensure proper newlines at end of file - Add trailing whitespace removal for Lua and Markdown files - Update output messages to reflect new processing steps - Maintain existing markdownlint formatting functionality
1 parent eb0037b commit 0366fb2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,17 @@ format:
108108
@echo "$(PURPLE)$(ARROW)$(RESET) $(PINK)$(BOLD)Formatting Code$(RESET)"
109109
@echo ""
110110
@echo " $(CYAN)$(DOT)$(RESET) Running stylua..."
111-
@if stylua --check lua/ colors/ >/dev/null 2>&1; then \
112-
echo " $(GREEN)$(CHECK)$(RESET) Lua code is properly formatted"; \
113-
else \
114-
echo " $(YELLOW)$(DOT)$(RESET) Formatting Lua code..."; \
115-
stylua lua/ colors/; \
116-
echo " $(GREEN)$(CHECK)$(RESET) Lua code formatted"; \
117-
fi
111+
@echo " $(YELLOW)$(DOT)$(RESET) Formatting Lua files..."
112+
@find . -name "*.lua" -type f | xargs stylua
113+
@echo " $(GREEN)$(CHECK)$(RESET) Lua code formatted"
114+
@echo ""
115+
@echo " $(CYAN)$(DOT)$(RESET) Fixing file endings..."
116+
@find . -name "*.lua" -o -name "*.md" -type f | xargs -I {} sh -c 'tail -c1 {} | read -r _ || echo >> {}'
117+
@echo " $(GREEN)$(CHECK)$(RESET) File endings fixed"
118+
@echo ""
119+
@echo " $(CYAN)$(DOT)$(RESET) Trimming trailing whitespace..."
120+
@find . -name "*.lua" -o -name "*.md" -type f | xargs sed -i '' -e 's/[[:space:]]*$$//'
121+
@echo " $(GREEN)$(CHECK)$(RESET) Trailing whitespace removed"
118122
@echo ""
119123
@echo " $(CYAN)$(DOT)$(RESET) Running markdownlint..."
120124
@echo " $(YELLOW)$(DOT)$(RESET) Formatting markdown files..."

0 commit comments

Comments
 (0)