Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions lib/asimov-module/src/models/module_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,33 @@ pub enum ReadVarError {
impl ModuleManifest {
#[cfg(all(feature = "std", feature = "serde"))]
pub fn read_manifest(module_name: &str) -> std::io::Result<Self> {
let path = asimov_env::paths::asimov_root()
.join("modules")
.join(std::format!("{module_name}.yaml"));
let content = std::fs::read(&path)?;
serde_yaml_ng::from_slice(&content).map_err(std::io::Error::other)
let directory = asimov_env::paths::asimov_root().join("modules");
let search_paths = [
("installed", "json"),
("installed", "yaml"), // legacy, new installs are converted to JSON
("", "yaml"), // legacy, new installs go to `installed/`
];

for (sub_dir, ext) in search_paths {
let file = std::path::PathBuf::from(sub_dir)
.join(module_name)
.with_extension(ext);

match std::fs::read(directory.join(&file)) {
Ok(content) if ext == "json" => {
return serde_json::from_slice(&content).map_err(std::io::Error::other);
},
Ok(content) if ext == "yaml" => {
Comment thread
artob marked this conversation as resolved.
return serde_yaml_ng::from_slice(&content).map_err(std::io::Error::other);
},
Ok(_) => unreachable!(),
Comment thread
artob marked this conversation as resolved.

Err(err) if err.kind() == std::io::ErrorKind::NotFound => continue,
Err(err) => return Err(err),
}
}

Err(std::io::ErrorKind::NotFound.into())
}

#[cfg(feature = "std")]
Expand Down
1 change: 0 additions & 1 deletion lib/asimov-snapshot/src/snapshot.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// This is free and unencumbered software released into the public domain.

use asimov_env::paths::asimov_root;
use asimov_module::resolve::Resolver;
use asimov_runner::{FetcherOptions, GraphOutput};
use jiff::Timestamp;
Expand Down