Skip to content

Commit

Permalink
Merge pull request #2288 from fzyzcjy/feat/12561
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Sep 12, 2024
2 parents b5839ff + 8e613e8 commit 9ab7435
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
9 changes: 2 additions & 7 deletions frb_codegen/src/library/codegen/polisher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub(super) fn polish(
"execute_build_runner",
);
warn_if_fail(
execute_dart_fix(config, output_paths, progress_bar_pack),
execute_dart_fix(config, progress_bar_pack),
"execute_dart_fix",
);

Expand Down Expand Up @@ -112,15 +112,10 @@ fn execute_build_runner(

fn execute_dart_fix(
config: &PolisherInternalConfig,
output_paths: &[PathBuf],
progress_bar_pack: &GeneratorProgressBarPack,
) -> anyhow::Result<()> {
let _pb = progress_bar_pack.polish_dart_fix.start();
dart_fix(
&filter_paths_by_extension(output_paths, "dart"),
&config.dart_root,
&["g.dart", "freezed.dart"],
)
dart_fix(&config.dart_root)
}

fn execute_dart_format(
Expand Down
13 changes: 3 additions & 10 deletions frb_codegen/src/library/commands/dart_fix.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
use crate::command_run;
use crate::commands::command_runner::call_shell;
use crate::library::commands::command_runner::check_exit_code;
use crate::library::commands::dart_format::prepare_paths;
use anyhow::Result;
use log::debug;
use std::path::{Path, PathBuf};
use std::path::Path;

#[allow(clippy::vec_init_then_push)]
pub fn dart_fix(paths: &[PathBuf], base_path: &Path, extra_extensions: &[&str]) -> Result<()> {
if paths.is_empty() {
return Ok(());
}

let paths = prepare_paths(paths, base_path, extra_extensions)?;
debug!("execute dart_fix paths={paths:?}");
pub fn dart_fix(base_path: &Path) -> Result<()> {
debug!("execute dart_fix");

let res = command_run!(
call_shell[Some(base_path), None],
"dart",
"fix",
"--apply",
*paths
)?;
check_exit_code(&res)?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion frb_codegen/src/library/integration/integrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn integrate(config: IntegrateConfig) -> Result<()> {
setup_cargokit_dependencies(&dart_root, &config.template)?;

info!("Apply Dart fixes");
dart_fix(&[dart_root.clone()], &dart_root, &[])?;
dart_fix(&dart_root)?;

info!("Format Dart code");
dart_format(&[dart_root.clone()], &dart_root, 80, &[])?;
Expand Down

0 comments on commit 9ab7435

Please sign in to comment.