-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Skip empty files during mix format
#11802
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
Conversation
Thank you for the PR! I believe we should make this change up in the |
29c6cae
to
71dba76
Compare
I took a look at |
lib/mix/lib/mix/tasks/format.ex
Outdated
@@ -561,7 +563,7 @@ defmodule Mix.Tasks.Format do | |||
|
|||
defp format_file({file, formatter}, task_opts) do | |||
input = read_file(file) | |||
output = formatter.(input) | |||
output = (bit_size(input) > 0 && formatter.(input)) || <<>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this change, given the change to elixir_format
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should skip empty files when formatting, but the change to elixir_format
skips formatting empty lines, and an empty file is just an empty line. Removed this piece of code from the PR as it was redundant. Thanks!
I see, makes sense! |
💚 💙 💜 💛 ❤️ |
Thank you @ak3nji for looking into it. |
Previously it was adding an empty line to empty files during the
mix format
task.This PR makes it so empty files are skipped and remain unchanged.
Fixes #11800