From 59d94e5484708ace3cbf8327e2eac80912494db6 Mon Sep 17 00:00:00 2001 From: wtlin1228 Date: Sat, 5 Oct 2024 17:31:25 +0800 Subject: [PATCH] feat: don't schedule test and spec --- crates/dt_scheduler/src/lib.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/dt_scheduler/src/lib.rs b/crates/dt_scheduler/src/lib.rs index ba60758..e2a19a3 100644 --- a/crates/dt_scheduler/src/lib.rs +++ b/crates/dt_scheduler/src/lib.rs @@ -104,9 +104,28 @@ impl ParserCandidateScheduler { } fn is_valid_path(path: &PathBuf) -> bool { - path.is_file() - && path.extension().is_some() - && ["ts", "tsx", "js", "jsx"].contains(&path.extension().unwrap().to_str().unwrap()) + if !path.is_file() { + return false; + } + let path_str = path.to_str().expect(&format!("to_str() for {:?}", path)); + if path_str.ends_with(".js") + || path_str.ends_with(".jsx") + || path_str.ends_with(".ts") + || path_str.ends_with(".tsx") + { + if !path_str.ends_with(".spec.js") + && !path_str.ends_with(".spec.jsx") + && !path_str.ends_with(".spec.ts") + && !path_str.ends_with(".spec.tsx") + && !path_str.ends_with(".test.js") + && !path_str.ends_with(".test.jsx") + && !path_str.ends_with(".test.ts") + && !path_str.ends_with(".test.tsx") + { + return true; + } + } + false } fn collect_paths(path: &PathBuf) -> Vec {