Skip to content

Commit 636dfac

Browse files
committed
fix(core): ensure source globs apply correctly
Fixes #312 Fixes #311 Reverts 34d9810
1 parent b22c443 commit 636dfac

File tree

3 files changed

+28
-89
lines changed

3 files changed

+28
-89
lines changed

Cargo.lock

Lines changed: 7 additions & 70 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
@@ -20,8 +20,8 @@ clap = { version = "4.5.53", features = ["cargo"] }
2020
color-print = "0.3.7"
2121
colored = "3.0.0"
2222
env_logger = "0.11.8"
23+
glob = "0.3.3"
2324
globset = "0.4.18"
24-
ignore = "0.4.25"
2525
indicatif = "0.18.3"
2626
itertools = "0.14.0"
2727
lazy_static = "1.5.0"

src/packages.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use {
88
rcfile::Rcfile,
99
specifier::Specifier,
1010
},
11-
ignore::{overrides::OverrideBuilder, WalkBuilder},
11+
glob::glob,
1212
log::debug,
1313
serde::Deserialize,
1414
serde_json::Value,
@@ -35,7 +35,6 @@ impl Packages {
3535
/// Get every package.json file matched by the user's source patterns
3636
pub fn from_config(config: &Config) -> Self {
3737
let file_paths = get_file_paths(config);
38-
debug!("Found file paths: {file_paths:?}");
3938
let mut packages = Self::new();
4039
file_paths.iter().for_each(|file_path| {
4140
if let Some(package_json) = PackageJson::from_file(file_path) {
@@ -178,18 +177,25 @@ pub fn normalize_pattern(pattern: String) -> String {
178177
/// Resolve every source glob pattern into their absolute file paths of
179178
/// package.json files
180179
fn get_file_paths(config: &Config) -> Vec<PathBuf> {
181-
let cwd = &config.cli.cwd;
182-
let source_patterns = get_source_patterns(config);
183-
let mut glob_filters = OverrideBuilder::new(cwd);
184-
for source_pattern in source_patterns {
185-
glob_filters.add(&source_pattern).unwrap();
186-
}
187-
WalkBuilder::new(cwd)
188-
.overrides(glob_filters.build().unwrap())
189-
.build()
190-
.filter_map(Result::ok)
191-
.filter(|entry| entry.file_type().is_some_and(|ft| ft.is_file()))
192-
.map(|entry| entry.into_path())
180+
get_source_patterns(config)
181+
.iter()
182+
.map(|pattern| {
183+
if PathBuf::from(pattern).is_absolute() {
184+
pattern.clone()
185+
} else {
186+
config.cli.cwd.join(pattern).to_str().unwrap().to_string()
187+
}
188+
})
189+
.flat_map(|pattern| glob(&pattern).ok())
190+
.flat_map(|paths| {
191+
paths
192+
.filter_map(Result::ok)
193+
.filter(|path| !path.to_string_lossy().contains("node_modules"))
194+
.fold(vec![], |mut paths, path| {
195+
paths.push(path.clone());
196+
paths
197+
})
198+
})
193199
.collect()
194200
}
195201

@@ -230,10 +236,6 @@ fn get_source_patterns(config: &Config) -> Vec<String> {
230236
})
231237
})
232238
.map(|patterns| patterns.into_iter().map(normalize_pattern).collect())
233-
.map(|patterns| {
234-
debug!("Found patterns: {patterns:?}");
235-
patterns
236-
})
237239
.or_else(get_default_patterns)
238240
.unwrap()
239241
}

0 commit comments

Comments
 (0)