-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix(fmt): use non-zero exit code when formatting fails #28523
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
tests/specs/fmt/html/broken.out
Outdated
@@ -1,4 +1,4 @@ | |||
Error formatting: [WILDCARD]broken.html | |||
Syntax error (expected close tag) at file://[WILDCARD]broken.html:3:0 | |||
|
|||
Checked 1 file | |||
error: Failed to format 1 file in 1 file |
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.
Nit: I feel like the duplicate file part is confusing to read. Maybe it should look something like this?
error: Failed to format 1 file
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 mirrors fmt --check
, which reports a result like error: Found 5 not formatted files in 10 files
This PR would cause fmt
to produce error: Failed to format 5 files in 10 files
I think all of these are reasonable:
- The suggested
error: Failed to format 5 files
- The existing
error: Failed to format 5 files in 10 files
- Some clearer message, e.g.
error: Failed to format 5 files of 10 checked files
Do you have a preference? And (if option 1 or option 3) should the message in fmt --check
be changed to match?
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.
@WWRS Can you change it to error: Failed to format 5 of 10 checked files
? Would be fine either way with changing deno fmt --check
to match.
Or let us know if you want us to finish the PR. We want to land this soon
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.
Nice work, also +1 on adding tests. Let's get rid of the duplicate file
part in the output and then I think it's ready to be merged.
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.
LGTM. Thanks!
Fixes #28483
RealFormatter
for files that failed to format (usually due to syntax error). If this isn't 0,finish
now returns an error.