feat(cli): use a single walker for all paths

This commit is contained in:
Boshen 2023-03-18 17:58:42 +08:00
parent 5135118bc8
commit 89542be81e
No known key found for this signature in database
GPG key ID: 6AC90C77AAAA6ABC
2 changed files with 14 additions and 8 deletions

View file

@ -65,12 +65,10 @@ impl LintRunner {
let fix = options.fix;
rayon::join(
move || {
options.paths.iter().flat_map(|path| Walk::new(path, options).iter()).for_each(
|path| {
*number_of_files += 1;
tx_path.send(path).unwrap();
},
)
Walk::new(options).iter().for_each(|path| {
*number_of_files += 1;
tx_path.send(path).unwrap();
});
},
move || {
while let Ok(path) = rx_path.recv() {

View file

@ -10,8 +10,16 @@ pub struct Walk {
}
impl Walk {
pub fn new<P: AsRef<Path>>(path: P, options: &LintOptions) -> Self {
let mut inner = WalkBuilder::new(path);
#[must_use]
pub fn new(options: &LintOptions) -> Self {
let mut inner = WalkBuilder::new(&options.paths[0]);
if let Some(paths) = options.paths.get(1..) {
for path in paths {
inner.add(path);
}
}
if !options.no_ignore {
inner.add_custom_ignore_filename(&options.ignore_path);
}