Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error when generation fails #144

Merged
merged 2 commits into from
Sep 11, 2023
Merged

Conversation

veggiemonk
Copy link
Contributor

This caught me by surprise when using air to auto-rebuild.

The file.templ was invalid and templ generate does not fail, it just prints the error. It caused the logical AND to succeed and rebuild while I kept working on the project and wondering why I'm not seeing my changes.

cmd = "templ generate && go build -o ./tmp/main ."

With this changes, it fails and the server dies, which is what I was expecting.
Maybe it is just me, let me know what you think.

Cheers

@a-h a-h merged commit 331bd73 into a-h:main Sep 11, 2023
3 checks passed
@a-h
Copy link
Owner

a-h commented Sep 11, 2023

Thanks, sorry for that. I missed that it used to return a non-zero exit code when template generation failed, but I broke it when I implemented a basic hot reload (it doesn't use a filesystem watching library because non of them worked well across all platforms).

I would be interested in your thoughts on the built-in hot reload, since you're using hot reload as part of your workflow: https://templ.guide/commands-and-tools/hot-reload

a-h pushed a commit that referenced this pull request Sep 24, 2023
…n non-watch mode

* return error when generation fails

* fix: return non-zero exit code on failure in non-watch mode

---------

Co-authored-by: Adrian Hesketh <[email protected]>

Fixes (#144)
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.

2 participants