Skip to content

Commit fcf0a9d

Browse files
committed
promote sources to auto source detection
1 parent 9b25bf8 commit fcf0a9d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

crates/oxide/src/lib.rs

+28
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,34 @@ impl Scanner {
219219
self.files.extend(files);
220220
self.globs.extend(globs);
221221
}
222+
223+
// Find all `@source` globs that point to a directory. If so, promote the source to auto
224+
// source detection instead.
225+
if let Some(sources) = &mut self.sources {
226+
for source in sources {
227+
// If a glob ends with `**/*`, then we just want to register the base path as a new
228+
// base.
229+
if source.pattern.ends_with("**/*") {
230+
source.pattern = source.pattern.trim_end_matches("**/*").to_owned();
231+
}
232+
233+
let path = PathBuf::from(&source.base).join(&source.pattern);
234+
if let Some(folder_name) = path.file_name() {
235+
// Contains a file extension, e.g.: `foo.html`, therefore we don't want to
236+
// detect sources here.
237+
if folder_name.to_str().unwrap().contains(".") {
238+
continue;
239+
}
240+
241+
// Promote to auto source detection
242+
let detect_sources = DetectSources::new(path.clone());
243+
244+
let (files, globs) = detect_sources.detect();
245+
self.files.extend(files);
246+
self.globs.extend(globs);
247+
}
248+
}
249+
}
222250
}
223251

224252
#[tracing::instrument(skip_all)]

0 commit comments

Comments
 (0)