You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that when chaining commands with the Templ CLI, it didn't matter whether the command succeeded or not.
In this example, given that the generation fails, I would expect templ generate to return a non-zero exit code, thus preventing the commands after it from executing.
templ generate && go run .
This, however, does not happen. I've taken a quick look at the code and it appears the non-zero status code is actually returned by the generateCmd function in cmd/templ/main.go, but it is ignored. The following is a snippet of the code:
The generate subcommand is not the only one affected, it's just the one I tested. Based on the code in the run function, returned exit codes are ignored for all subcommands.
The text was updated successfully, but these errors were encountered:
a-h
added a commit
that referenced
this issue
Nov 3, 2023
Hello,
I've noticed that when chaining commands with the Templ CLI, it didn't matter whether the command succeeded or not.
In this example, given that the generation fails, I would expect
templ generate
to return a non-zero exit code, thus preventing the commands after it from executing.This, however, does not happen. I've taken a quick look at the code and it appears the non-zero status code is actually returned by the
generateCmd
function in cmd/templ/main.go, but it is ignored. The following is a snippet of the code:Based on this, the solution might be just returning the exit code, but I'm unsure whether there is a reason for it being this way I'm not seeing:
It would also be required to handle it in
main
which might look something like this:The
generate
subcommand is not the only one affected, it's just the one I tested. Based on the code in therun
function, returned exit codes are ignored for all subcommands.The text was updated successfully, but these errors were encountered: