Skip to content

Commit

Permalink
fix(forc-fmt): propagate error on failure (FuelLabs#4222)
Browse files Browse the repository at this point in the history
## Description

closes FuelLabs#4163

In a previous refactor PR that I submitted the error propagation was
accidentally suppressed, causing the formatter to not exit with 1 on
error.


## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <[email protected]>
  • Loading branch information
eightfilms and JoshuaBatty authored Mar 6, 2023
1 parent cfb5d48 commit 3c7eac1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions forc-plugins/forc-fmt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ fn format_workspace_at_dir(app: &App, workspace: &WorkspaceManifestFile, dir: &P
let manifest_file = dir.join(constants::MANIFEST_FILE_NAME);

// Finally, format the root manifest using taplo formatter
if let Ok(edited) = format_manifest(app, manifest_file) {
contains_edits |= edited;
}
contains_edits |= format_manifest(app, manifest_file)?;

if app.check && contains_edits {
// One or more files are not formatted, exit with error
Expand Down Expand Up @@ -262,14 +260,10 @@ fn format_pkg_at_dir(app: &App, dir: &Path, formatter: &mut Formatter) -> Result
let mut contains_edits = false;

for file in files {
if let Ok(edited) = format_file(app, file, Some(manifest_file.clone()), formatter) {
contains_edits |= edited;
};
contains_edits |= format_file(app, file, Some(manifest_file.clone()), formatter)?;
}
// format manifest using taplo formatter
if let Ok(edited) = format_manifest(app, manifest_file) {
contains_edits |= edited;
}
contains_edits |= format_manifest(app, manifest_file)?;

if app.check && contains_edits {
// One or more files are not formatted, exit with error
Expand Down

0 comments on commit 3c7eac1

Please sign in to comment.