Skip to content

Commit

Permalink
fix: fix func get_kcl_files (#912)
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa authored Nov 23, 2023
1 parent 6096c41 commit 0085d75
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions kclvm/driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,16 @@ pub fn lookup_compile_unit_path(file: &str) -> io::Result<PathBuf> {
/// Get kcl files from path.
pub fn get_kcl_files<P: AsRef<Path>>(path: P, recursively: bool) -> Result<Vec<String>> {
let mut files = vec![];
for entry in WalkDir::new(path).into_iter().filter_map(|e| e.ok()) {
let walkdir = if recursively {
WalkDir::new(path)
} else {
WalkDir::new(path).max_depth(1)
};
for entry in walkdir.into_iter().filter_map(|e| e.ok()) {
let path = entry.path();
if path.is_file() {
let file = path.to_str().unwrap();
if file.ends_with(KCL_FILE_SUFFIX) && (recursively || entry.depth() == 1) {
if file.ends_with(KCL_FILE_SUFFIX) {
files.push(file.to_string())
}
}
Expand Down

0 comments on commit 0085d75

Please sign in to comment.