Skip to content

Commit d612e66

Browse files
committed
expand patterns in GlobEntry
1 parent 2cc2a33 commit d612e66

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/oxide/src/lib.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::parser::Extractor;
22
use crate::scanner::detect_sources::DetectSources;
3+
use bexpand::Expression;
34
use bstr::ByteSlice;
45
use fxhash::{FxHashMap, FxHashSet};
56
use glob::fast_glob;
@@ -217,6 +218,26 @@ impl Scanner {
217218
return;
218219
}
219220

221+
// Expand glob patterns and create new `GlobEntry` instances for each expanded pattern.
222+
let sources = sources
223+
.iter()
224+
.flat_map(|source| {
225+
let expression: Result<Expression, _> = source.pattern[..].try_into();
226+
let Ok(expression) = expression else {
227+
return vec![source.clone()];
228+
};
229+
230+
expression
231+
.into_iter()
232+
.filter_map(|expanded_pattern| expanded_pattern.map(|x| x.into()).ok())
233+
.map(move |pattern| GlobEntry {
234+
base: source.base.clone(),
235+
pattern,
236+
})
237+
.collect::<Vec<_>>()
238+
})
239+
.collect::<Vec<_>>();
240+
220241
// Partition sources into sources that should be promoted to auto source detection and
221242
// sources that should be resolved as globs.
222243
let (auto_sources, glob_sources): (Vec<_>, Vec<_>) = sources.iter().partition(|source| {

0 commit comments

Comments
 (0)