fn locate_project_config_file<T>(
    name: &str,
    template_folder: T,
    subfolder: &Option<PathBuf>,
) -> Result<PathBuf>
where
    T: AsRef<Path>,
{
    let template_folder = template_folder.as_ref().to_path_buf();
    let mut search_folder = subfolder
        .as_ref()
        .map_or_else(|| template_folder.to_owned(), |s| template_folder.join(s));
    loop {
        let file_path = search_folder.join(name.borrow());
        if file_path.exists() {
            return Ok(file_path);
        }
        if search_folder == template_folder {
            return Err(any_msg("File not found within template", ""));
        }
        search_folder = search_folder
            .parent()
            .ok_or_else(|| {
                any_msg(
                    "Missing Config:",
                    &format!(
                        "did not find {} in {} or any of its parents.",
                        &search_folder.display(),
                        CONFIG_FILE_NAME
                    ),
                )
            })?
            .to_path_buf();
    }
}
/// Finds template configuration in subfolder or a parent.
/// Returns error if no configuration was found
Finds template configuration in subfolder or a parent.
Returns error if no configuration was found
Finds template configuration in subfolder or a parent . Returns error if no configuration was found
fn locate_project_config_file<T>(
    name: &str,
    template_folder: T,
    subfolder: &Option<PathBuf>,
) -> Result<PathBuf>
where
    T: AsRef<Path>,
{
    let template_folder = template_folder.as_ref().to_path_buf();
    let mut search_folder = subfolder
        .as_ref()
        .map_or_else(|| template_folder.to_owned(), |s| template_folder.join(s));
    loop {
        let file_path = search_folder.join(name.borrow());
        if file_path.exists() {
            return Ok(file_path);
        }
        if search_folder == template_folder {
            return Err(any_msg("File not found within template", ""));
        }
        search_folder = search_folder
            .parent()
            .ok_or_else(|| {
                any_msg(
                    "Missing Config:",
                    &format!(
                        "did not find {} in {} or any of its parents.",
                        &search_folder.display(),
                        CONFIG_FILE_NAME
                    ),
                )
            })?
            .to_path_buf();
    }
}
fn locate_project_config_file < T > ( name : & str , template_folder : T , subfolder : & Option < PathBuf > , ) -> Result < PathBuf > where T : AsRef < Path > , { let template_folder = template_folder . as_ref ( ) . to_path_buf ( ) ; let mut search_folder = subfolder . as_ref ( ) . map_or_else ( | | template_folder . to_owned ( ) , | s | template_folder . join ( s ) ) ; loop { let file_path = search_folder . join ( name . borrow ( ) ) ; if file_path . exists ( ) { return Ok ( file_path ) ; } if search_folder == template_folder { return Err ( any_msg ( " " , " " ) ) ; } search_folder = search_folder . parent ( ) . ok_or_else ( | | { any_msg ( " " , & format ! ( " " search_folder display ( ) CONFIG_FILE_NAME ) , ) } ) ? . to_path_buf ( ) ; } }
Finds template configuration in subfolder or a parent.
Finds template configuration in subfolder or a parent .
name
&str
template_folder
T
subfolder
&Option<PathBuf>