Skip to main content

yog_cli/design/
project.rs

1//! A mod project as the designers see it: the manifest at its root and the
2//! mod a file is in.
3
4use std::path::{Path, PathBuf};
5
6pub use crate::media::mod_id;
7
8/// `<root>/yog.toml`.
9pub fn path(root: &Path) -> PathBuf {
10    root.join(yog_ids::file::MANIFEST)
11}
12
13/// The mod `file` belongs to: the nearest folder (itself included) with a `yog.toml`.
14pub fn mod_root(file: &Path) -> Option<PathBuf> {
15    file.ancestors().find(|d| path(d).is_file()).map(Path::to_path_buf)
16}