Skip to content

Commit

Permalink
fix(tasks/ast_codegen): run cargo fmt synchronously (#4181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jul 11, 2024
1 parent 07506ec commit 8c54a2f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,6 @@ jobs:
- name: Check AST Changes
if: steps.filter.outputs.src == 'true'
run: |
cargo run -p oxc_ast_codegen -- --no-fmt
# FIXME:
# remove the following command and `--no-fmt` flag
# for some reason in the CI `cargo fmt` in the `oxc_ast_codegen` doesn't produce formatted code,
# Even though it is running succesfully and produces no errors.
# It also prints the right results for `cargo fmt --version` so it can find the right binary for sure.
cargo fmt
cargo run -p oxc_ast_codegen
echo 'AST changes must be commited to the repo.'
git diff --exit-code
13 changes: 3 additions & 10 deletions tasks/ast_codegen/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,7 @@ pub fn pprint(input: &TokenStream) -> String {
result
}

/// Runs cargo fmt in the `root` path.
pub fn cargo_fmt(root: &str) -> std::io::Result<()> {
let mut cmd = Command::new("cargo");
cmd.arg("fmt")
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.current_dir(root);
cmd.spawn()?;
Ok(())
/// Runs cargo fmt.
pub fn cargo_fmt() {
Command::new("cargo").arg("fmt").status().unwrap();
}
2 changes: 1 addition & 1 deletion tasks/ast_codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
}

if !cli_options.no_fmt {
cargo_fmt(".")?;
cargo_fmt();
}

if let CliOptions { schema: Some(schema_path), dry_run: false, .. } = cli_options {
Expand Down

0 comments on commit 8c54a2f

Please sign in to comment.