Skip to content

Commit d0f9d26

Browse files
dsherretzebreus
authored andcommitted
fix(workspace): better cli file argument handling (denoland#24447)
Closes denoland#24422
1 parent 12b10ca commit d0f9d26

File tree

10 files changed

+84
-296
lines changed

10 files changed

+84
-296
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ console_static_text = "=0.8.1"
101101
data-encoding = "2.3.3"
102102
data-url = "=0.3.0"
103103
deno_cache_dir = "=0.10.0"
104-
deno_config = { version = "=0.20.0", default-features = false }
104+
deno_config = { version = "=0.20.1", default-features = false }
105105
dlopen2 = "0.6.1"
106106
ecb = "=0.1.2"
107107
elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] }

cli/args/flags.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use log::debug;
2525
use log::Level;
2626
use serde::Deserialize;
2727
use serde::Serialize;
28+
use std::collections::HashSet;
2829
use std::env;
2930
use std::ffi::OsString;
3031
use std::net::SocketAddr;
@@ -36,7 +37,6 @@ use std::path::PathBuf;
3637
use std::str::FromStr;
3738

3839
use crate::args::resolve_no_prompt;
39-
use crate::util::collections::CheckedSet;
4040
use crate::util::fs::canonicalize_path;
4141

4242
use super::flags_net;
@@ -865,20 +865,20 @@ impl Flags {
865865
args
866866
}
867867

868-
/// Extract the directory paths the config file should be discovered from.
868+
/// Extract the paths the config file should be discovered from.
869869
///
870870
/// Returns `None` if the config file should not be auto-discovered.
871871
pub fn config_path_args(&self, current_dir: &Path) -> Option<Vec<PathBuf>> {
872872
fn resolve_multiple_files(
873-
files: &[String],
873+
files_or_dirs: &[String],
874874
current_dir: &Path,
875875
) -> Vec<PathBuf> {
876-
let mut seen = CheckedSet::with_capacity(files.len());
877-
let result = files
876+
let mut seen = HashSet::with_capacity(files_or_dirs.len());
877+
let result = files_or_dirs
878878
.iter()
879879
.filter_map(|p| {
880-
let path = normalize_path(current_dir.join(p).parent()?);
881-
if seen.insert(&path) {
880+
let path = normalize_path(current_dir.join(p));
881+
if seen.insert(path.clone()) {
882882
Some(path)
883883
} else {
884884
None
@@ -9298,7 +9298,7 @@ mod tests {
92989298
.unwrap();
92999299
assert_eq!(
93009300
flags.config_path_args(&cwd),
9301-
Some(vec![cwd.join("dir/a/"), cwd.join("dir/b/")])
9301+
Some(vec![cwd.join("dir/a/a.js"), cwd.join("dir/b/b.js")])
93029302
);
93039303

93049304
let flags = flags_from_vec(svec!["deno", "lint"]).unwrap();
@@ -9314,7 +9314,11 @@ mod tests {
93149314
.unwrap();
93159315
assert_eq!(
93169316
flags.config_path_args(&cwd),
9317-
Some(vec![cwd.join("dir/a/"), cwd.join("dir/")])
9317+
Some(vec![
9318+
cwd.join("dir/a/a.js"),
9319+
cwd.join("dir/a/a2.js"),
9320+
cwd.join("dir/b.js")
9321+
])
93189322
);
93199323
}
93209324

0 commit comments

Comments
 (0)