use std::path::{Path, PathBuf};
const VALIDATOR_DIR: &str = "knishio-validator-rust";
pub fn find_compose_file(start: &Path, compose_filename: &str) -> Option<PathBuf> {
let mut dir = start.to_path_buf();
loop {
let candidate = dir.join(compose_filename);
if candidate.exists() {
return Some(candidate);
}
let candidate = dir.join(VALIDATOR_DIR).join(compose_filename);
if candidate.exists() {
return Some(candidate);
}
let candidate = dir.join("servers").join(VALIDATOR_DIR).join(compose_filename);
if candidate.exists() {
return Some(candidate);
}
if !dir.pop() {
break;
}
}
None
}