Closed roryqueue closed 3 years ago
@roryqueue Thanks for reporting this issue! I haven't heard of this problem before, but it makes sense that it would happen.
I think this is something I'm not going to fix at this time because the inject_before_final_end/2
function is a pattern that's borrowed from the rest of the Phoenix generators and I'd like to maintain consistency with them. If we were to address this issue, it should be solved for all of the phoenix generators at the same time. That said, I haven't heard of many people putting comments after the final end in a file, so we'd have to make the determination if addressing this edge case is worth the changes that would need to be made. :)
Hey Aaron and all, thanks for all your work. I'm using the this generator for the first time and I noticed something minor-- I had a comment at the end of my router file (for a dumb reason), which caused it the final "end" in the router module to be duplicated instead of replaced, which subsequently caused the generated code to fail to compile on first try.
The relevant generation code is here. I'm happy to open a PR to adjust the behavior for this scenario (cut from the last "end" on, inject code, then paste cut code back after) if this is something you think IS actually unwanted behavior and SHOULD be fixed. I also won't offended if you'd prefer to keep the same behavior, say "don't add stuff to the end of your router file," and move on. In that case please just close this issue.