-
Notifications
You must be signed in to change notification settings - Fork 552
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
Ability to have gsub_file
error if it didn't gsub anything
#874
Comments
G-Rath
added a commit
to ackama/rails-template
that referenced
this issue
Mar 8, 2024
…o longer doing anything (#533) So it turns out that `gsub_file` does not actually check if it matched anything and so we have a few misc. changes silently not being applied due to changes in Rails 7.1. This addresses that by switching us to use `gsub_file!` which reads the file into memory before it's gsub'd and then compares the results to make sure it actually changed. I've opened rails/thor#874 to add this to Thor itself
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently discovered that
gsub_file
does not error when it does not match; this feels like a bit of a footgun to me.I've worked around this using this utility function to ensure the file contents has changed:
However, I think it would be a good addition to
thor
itself - I'm thinking maybegsub_file "", "", "", error_on_no_change: true
and then an alias ofgsub_file!
?The text was updated successfully, but these errors were encountered: