diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-08 10:12:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 14:12:10 +0000 |
commit | 86010bec092d074b161800da06149cfb79fb9f4b (patch) | |
tree | 78ab91b1fffc53ff8a56fc86e2c6f0459b21a129 /cli/args/flags.rs | |
parent | 1e97f0f1487d27b69d85ebe8e9d84c21af1d9dde (diff) |
fix(workspace): better cli file argument handling (#24447)
Closes https://github.com/denoland/deno/issues/24422
Diffstat (limited to 'cli/args/flags.rs')
-rw-r--r-- | cli/args/flags.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/cli/args/flags.rs b/cli/args/flags.rs index b68b4aadb..89f53d593 100644 --- a/cli/args/flags.rs +++ b/cli/args/flags.rs @@ -25,6 +25,7 @@ use log::debug; use log::Level; use serde::Deserialize; use serde::Serialize; +use std::collections::HashSet; use std::env; use std::ffi::OsString; use std::net::SocketAddr; @@ -36,7 +37,6 @@ use std::path::PathBuf; use std::str::FromStr; use crate::args::resolve_no_prompt; -use crate::util::collections::CheckedSet; use crate::util::fs::canonicalize_path; use super::flags_net; @@ -865,20 +865,20 @@ impl Flags { args } - /// Extract the directory paths the config file should be discovered from. + /// Extract the paths the config file should be discovered from. /// /// Returns `None` if the config file should not be auto-discovered. pub fn config_path_args(&self, current_dir: &Path) -> Option<Vec<PathBuf>> { fn resolve_multiple_files( - files: &[String], + files_or_dirs: &[String], current_dir: &Path, ) -> Vec<PathBuf> { - let mut seen = CheckedSet::with_capacity(files.len()); - let result = files + let mut seen = HashSet::with_capacity(files_or_dirs.len()); + let result = files_or_dirs .iter() .filter_map(|p| { - let path = normalize_path(current_dir.join(p).parent()?); - if seen.insert(&path) { + let path = normalize_path(current_dir.join(p)); + if seen.insert(path.clone()) { Some(path) } else { None @@ -9298,7 +9298,7 @@ mod tests { .unwrap(); assert_eq!( flags.config_path_args(&cwd), - Some(vec![cwd.join("dir/a/"), cwd.join("dir/b/")]) + Some(vec![cwd.join("dir/a/a.js"), cwd.join("dir/b/b.js")]) ); let flags = flags_from_vec(svec!["deno", "lint"]).unwrap(); @@ -9314,7 +9314,11 @@ mod tests { .unwrap(); assert_eq!( flags.config_path_args(&cwd), - Some(vec![cwd.join("dir/a/"), cwd.join("dir/")]) + Some(vec![ + cwd.join("dir/a/a.js"), + cwd.join("dir/a/a2.js"), + cwd.join("dir/b.js") + ]) ); } |