summaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-04 01:13:09 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-04 01:16:43 +0200
commit1896ea04204b8086a4f25e257dc5605e5505d768 (patch)
tree694b5298958c0152ce4fe58c42f864980fd6b9df /crates
parentaa914e75251af3f9691be621a8c266320158bace (diff)
downloadrebel-1896ea04204b8086a4f25e257dc5605e5505d768.tar
rebel-1896ea04204b8086a4f25e257dc5605e5505d768.zip
driver: recipe: move each recipe into a separate directory
Diffstat (limited to 'crates')
-rw-r--r--crates/driver/src/recipe.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/driver/src/recipe.rs b/crates/driver/src/recipe.rs
index ec1c116..3a033f1 100644
--- a/crates/driver/src/recipe.rs
+++ b/crates/driver/src/recipe.rs
@@ -1,4 +1,4 @@
-use std::{collections::HashMap, fs::File, path::Path, result};
+use std::{collections::HashMap, ffi::OsStr, fs::File, path::Path, result};
use scoped_tls_hkt::scoped_thread_local;
use serde::{Deserialize, Deserializer};
@@ -47,8 +47,8 @@ fn read_recipe(path: &Path) -> Result<Recipe> {
Ok(recipe)
}
-fn is_yml(path: &Path) -> bool {
- path.extension() == Some("yml".as_ref())
+fn is_recipe(path: &Path) -> bool {
+ path.file_name().unwrap_or_default() == "build.yml"
}
pub fn read_recipes<P: AsRef<Path>>(path: P) -> Result<HashMap<TaskID, Vec<TaskDef>>> {
@@ -60,11 +60,15 @@ pub fn read_recipes<P: AsRef<Path>>(path: P) -> Result<HashMap<TaskID, Vec<TaskD
.filter_map(|e| e.ok())
{
let path = entry.path();
- if !path.is_file() || !is_yml(path) {
+ if !path.is_file() || !is_recipe(path) {
continue;
}
- let Some(Some(basename)) = path.file_stem().map(|n| n.to_str()) else {
+ let Some(basename) = path
+ .parent()
+ .and_then(Path::file_name)
+ .and_then(OsStr::to_str)
+ else {
continue;
};