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 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:
def gsub_file!(path, flag, *args, &block)
content = File.binread(path)
gsub_file(path, flag, *args, &block)
raise StandardError, "the contents of #{path} did not change!" if content == File.binread(path)
end
However, I think it would be a good addition to thor itself - I'm thinking maybe gsub_file "", "", "", error_on_no_change: true and then an alias of gsub_file!?