Skip to content

fix: don't attempt to apply prettier if it is not available#1246

Merged
a-h merged 1 commit intomainfrom
issue_1244
Aug 15, 2025
Merged

fix: don't attempt to apply prettier if it is not available#1246
a-h merged 1 commit intomainfrom
issue_1244

Conversation

@a-h
Copy link
Copy Markdown
Owner

@a-h a-h commented Aug 15, 2025

Fixes #1244

@a-h a-h requested a review from Copilot August 15, 2025 14:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where the formatter would fail when prettier is not installed by adding graceful handling for missing prettier commands. The fix modifies the applyPrettier function to skip prettier formatting when it's not available (unless explicitly required) rather than failing entirely.

  • Adds availability check for prettier command before attempting to use it
  • Returns early with no error when prettier is unavailable and not required
  • Improves error message to include the specific command when prettier is required but unavailable

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/format/templ.go Modified applyPrettier function to check prettier availability and handle graceful fallback
internal/prettier/prettier_test.go Added test coverage for the IsAvailable function with both positive and negative cases

@a-h a-h merged commit 18fb42a into main Aug 15, 2025
9 checks passed
@a-h a-h deleted the issue_1244 branch August 15, 2025 14:52
dgrundel pushed a commit to dgrundel/templ that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prettier not found

2 participants