mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Move responsibility for extracting names from paths lower
This commit is contained in:
@@ -9,12 +9,15 @@ use crate::{
|
||||
snapshot::{InstanceContext, InstanceSnapshot},
|
||||
};
|
||||
|
||||
use super::util::PathExt;
|
||||
|
||||
pub fn snapshot_json_model(
|
||||
context: &InstanceContext,
|
||||
vfs: &Vfs,
|
||||
path: &Path,
|
||||
instance_name: &str,
|
||||
) -> anyhow::Result<Option<InstanceSnapshot>> {
|
||||
let name = path.file_name_trim_end(".model.json")?;
|
||||
|
||||
let contents = vfs.read(path)?;
|
||||
let contents_str = str::from_utf8(&contents)
|
||||
.with_context(|| format!("File was not valid UTF-8: {}", path.display()))?;
|
||||
@@ -28,7 +31,7 @@ pub fn snapshot_json_model(
|
||||
|
||||
let mut snapshot = instance
|
||||
.core
|
||||
.into_snapshot(instance_name.to_owned())
|
||||
.into_snapshot(name.to_owned())
|
||||
.with_context(|| format!("Could not load JSON model: {}", path.display()))?;
|
||||
|
||||
snapshot.metadata = snapshot
|
||||
@@ -133,7 +136,6 @@ mod test {
|
||||
&InstanceContext::default(),
|
||||
&mut vfs,
|
||||
Path::new("/foo.model.json"),
|
||||
"foo",
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user