Closed remi closed 6 years ago
Yup, we should not write the files. A quick benchmark I ran locally even showed that the formatter is faster if it is not writing on every change.
@josevalim I'd be happy to take a whack at this if it's not something you're already tackling 👍
@doomspork glad you asked because I am almost done with it! :D
@josevalim Wow, thank you for fixing this so quickly! This removed the frustration of having to restart my Phoenix server each time I run mix format
on a config file! 🎉 😀
If
mix format
is ran on a file and its content is not changed by the formatter, its modification time is still updated.Environment
Elixir & Erlang versions (elixir --version):
Operating system:
Current behavior
We can see the file’s
mtime
attribute has been updated but its content stayed the same (hence the same md5 hash).The problem with this is that it doesn’t play well with Phoenix code reloading feature (and probably other tools that look at file modification times to detect file updates) which requires the developer to restart its server when a config file has been modified (based on
mtime
):It this by design in
mix format
or is it a bug? Should the file be touched even if its content was not changed by the formatter?Expected behavior
If
mix format
doesn’t change the content of a file, it should not change its modification time.Thank you! 😄