Skip to content

Commit

Permalink
!squash Extract is_yaml, simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorella-dev committed May 19, 2024
1 parent 5f4f096 commit b4c9139
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/cmd/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,22 @@ fn kill_process_by_name(name: &str) {
}
}

fn is_yaml(path: &Utf8PathBuf) -> bool {
path.extension()
.map(|ext| ext.to_ascii_lowercase())
.map(|ext| ext == "yml" || ext == "yaml")
.unwrap_or(false)
}

pub fn process_path(path: Utf8PathBuf) -> Result<Vec<Utf8PathBuf>> {
//
match path {
path if path.is_file() => Ok(vec![path]),
path if path.is_dir() => {
let mut files = path
.read_dir_utf8()?
.filter_map(Result::ok)
.filter(|entry| entry.path().extension().map_or(false, |ext| ext == "yml" || ext == "yaml"))
.map(|entry| entry.into_path())
.filter(is_yaml)
.collect::<Vec<Utf8PathBuf>>();

files.sort();
Expand Down

0 comments on commit b4c9139

Please sign in to comment.