From d170304a596198999c0617a94103a17381f903cd Mon Sep 17 00:00:00 2001 From: Dangerise <2237556709@qq.com> Date: Tue, 6 Feb 2024 21:01:33 +0800 Subject: [PATCH] remove dead code --- packages/cli/src/cli/autoformat.rs | 43 +----------------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/packages/cli/src/cli/autoformat.rs b/packages/cli/src/cli/autoformat.rs index bcf9b266f..b1ec83a66 100644 --- a/packages/cli/src/cli/autoformat.rs +++ b/packages/cli/src/cli/autoformat.rs @@ -1,6 +1,6 @@ use dioxus_autofmt::{IndentOptions, IndentType}; use rayon::prelude::*; -use std::{fs, path::Path, process::exit}; +use std::{fs, io, path::Path, process::exit}; use super::*; @@ -119,20 +119,6 @@ fn get_project_files() -> Vec { files } -#[allow(dead_code)] -fn is_target_dir(file: &Path) -> bool { - let stripped = if let Ok(cwd) = std::env::current_dir() { - file.strip_prefix(cwd).unwrap_or(file) - } else { - file - }; - if let Some(first) = stripped.components().next() { - first.as_os_str() == "target" - } else { - false - } -} - fn format_file(path: impl AsRef, indent: IndentOptions, do_rustfmt: bool) -> Result { let mut contents = fs::read_to_string(&path)?; let mut if_write = false; @@ -174,8 +160,6 @@ async fn autoformat_project( ) -> Result<()> { let files_to_format = get_project_files(); - dbg!(&files_to_format); - if files_to_format.is_empty() { return Ok(()); } @@ -253,31 +237,6 @@ fn indentation_for( )) } -#[allow(dead_code)] -fn collect_rs_files(folder: &impl AsRef, files: &mut Vec) { - if is_target_dir(folder.as_ref()) { - return; - } - let Ok(folder) = folder.as_ref().read_dir() else { - return; - }; - // load the gitignore - for entry in folder { - let Ok(entry) = entry else { - continue; - }; - let path = entry.path(); - if path.is_dir() { - collect_rs_files(&path, files); - } - if let Some(ext) = path.extension() { - if ext == "rs" && !is_target_dir(&path) { - files.push(path); - } - } - } -} - #[tokio::test] async fn test_auto_fmt() { let test_rsx = r#"