Skip to content

Commit

Permalink
Merge pull request #184 from c12i/fix-file-in-ui-framewwork-options
Browse files Browse the repository at this point in the history
fix: address file presence in choose_or_get_template options
  • Loading branch information
c12i authored Jan 19, 2024
2 parents dc10337 + b85f69e commit 508f3a1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,15 @@ pub fn choose_or_get_template(
let templates_dir_content =
dir_content(file_tree, &templates_path).map_err(|_e| ScaffoldError::NoTemplatesFound)?;

let templates: Vec<String> = templates_dir_content
.into_keys()
.map(|k| k.to_str().unwrap().to_string())
.collect();
let templates = templates_dir_content
.iter()
.filter_map(|(k, v)| {
if v.file_content().is_some() {
return None;
}
k.to_str().map(|s| s.to_string())
})
.collect::<Vec<String>>();

let chosen_template_name = match (template, templates.len()) {
(_, 0) => Err(ScaffoldError::NoTemplatesFound),
Expand Down

0 comments on commit 508f3a1

Please sign in to comment.