mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-26 15:46:28 +00:00
Merge branch 'feature/init-name-resolution'
This commit is contained in:
@@ -109,27 +109,17 @@ pub fn syncback_csv<'sync>(
|
|||||||
|
|
||||||
if !meta.is_empty() {
|
if !meta.is_empty() {
|
||||||
let parent = snapshot.path.parent_err()?;
|
let parent = snapshot.path.parent_err()?;
|
||||||
let meta_stem = snapshot.middleware
|
let instance_name = &new_inst.name;
|
||||||
.and_then(|mw| {
|
let base = if crate::syncback::validate_file_name(instance_name).is_err() {
|
||||||
let ext = format!(".{}", crate::syncback::extension_for_middleware(mw));
|
crate::syncback::slugify_name(instance_name)
|
||||||
snapshot.path.file_name()
|
} else {
|
||||||
.and_then(|n| n.to_str())
|
instance_name.clone()
|
||||||
.and_then(|s| s.strip_suffix(ext.as_str()))
|
};
|
||||||
.map(str::to_owned)
|
let meta_stem = if base.to_lowercase() == "init" {
|
||||||
})
|
format!("_{base}")
|
||||||
.unwrap_or_else(|| {
|
} else {
|
||||||
let name = &new_inst.name;
|
base
|
||||||
let base = if crate::syncback::validate_file_name(name).is_err() {
|
};
|
||||||
crate::syncback::slugify_name(name)
|
|
||||||
} else {
|
|
||||||
name.clone()
|
|
||||||
};
|
|
||||||
if base.to_lowercase() == "init" {
|
|
||||||
format!("_{base}")
|
|
||||||
} else {
|
|
||||||
base
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs_snapshot.add_file(
|
fs_snapshot.add_file(
|
||||||
parent.join(format!("{meta_stem}.meta.json")),
|
parent.join(format!("{meta_stem}.meta.json")),
|
||||||
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
||||||
|
|||||||
@@ -158,27 +158,17 @@ pub fn syncback_lua<'sync>(
|
|||||||
|
|
||||||
if !meta.is_empty() {
|
if !meta.is_empty() {
|
||||||
let parent_location = snapshot.path.parent_err()?;
|
let parent_location = snapshot.path.parent_err()?;
|
||||||
let meta_stem = snapshot.middleware
|
let instance_name = &snapshot.new_inst().name;
|
||||||
.and_then(|mw| {
|
let base = if crate::syncback::validate_file_name(instance_name).is_err() {
|
||||||
let ext = format!(".{}", crate::syncback::extension_for_middleware(mw));
|
crate::syncback::slugify_name(instance_name)
|
||||||
snapshot.path.file_name()
|
} else {
|
||||||
.and_then(|n| n.to_str())
|
instance_name.clone()
|
||||||
.and_then(|s| s.strip_suffix(ext.as_str()))
|
};
|
||||||
.map(str::to_owned)
|
let meta_stem = if base.to_lowercase() == "init" {
|
||||||
})
|
format!("_{base}")
|
||||||
.unwrap_or_else(|| {
|
} else {
|
||||||
let name = &snapshot.new_inst().name;
|
base
|
||||||
let base = if crate::syncback::validate_file_name(name).is_err() {
|
};
|
||||||
crate::syncback::slugify_name(name)
|
|
||||||
} else {
|
|
||||||
name.clone()
|
|
||||||
};
|
|
||||||
if base.to_lowercase() == "init" {
|
|
||||||
format!("_{base}")
|
|
||||||
} else {
|
|
||||||
base
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs_snapshot.add_file(
|
fs_snapshot.add_file(
|
||||||
parent_location.join(format!("{meta_stem}.meta.json")),
|
parent_location.join(format!("{meta_stem}.meta.json")),
|
||||||
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
serde_json::to_vec_pretty(&meta).context("cannot serialize metadata")?,
|
||||||
|
|||||||
@@ -58,27 +58,17 @@ pub fn syncback_txt<'sync>(
|
|||||||
|
|
||||||
if !meta.is_empty() {
|
if !meta.is_empty() {
|
||||||
let parent = snapshot.path.parent_err()?;
|
let parent = snapshot.path.parent_err()?;
|
||||||
let meta_stem = snapshot.middleware
|
let instance_name = &new_inst.name;
|
||||||
.and_then(|mw| {
|
let base = if crate::syncback::validate_file_name(instance_name).is_err() {
|
||||||
let ext = format!(".{}", crate::syncback::extension_for_middleware(mw));
|
crate::syncback::slugify_name(instance_name)
|
||||||
snapshot.path.file_name()
|
} else {
|
||||||
.and_then(|n| n.to_str())
|
instance_name.clone()
|
||||||
.and_then(|s| s.strip_suffix(ext.as_str()))
|
};
|
||||||
.map(str::to_owned)
|
let meta_stem = if base.to_lowercase() == "init" {
|
||||||
})
|
format!("_{base}")
|
||||||
.unwrap_or_else(|| {
|
} else {
|
||||||
let name = &new_inst.name;
|
base
|
||||||
let base = if crate::syncback::validate_file_name(name).is_err() {
|
};
|
||||||
crate::syncback::slugify_name(name)
|
|
||||||
} else {
|
|
||||||
name.clone()
|
|
||||||
};
|
|
||||||
if base.to_lowercase() == "init" {
|
|
||||||
format!("_{base}")
|
|
||||||
} else {
|
|
||||||
base
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fs_snapshot.add_file(
|
fs_snapshot.add_file(
|
||||||
parent.join(format!("{meta_stem}.meta.json")),
|
parent.join(format!("{meta_stem}.meta.json")),
|
||||||
serde_json::to_vec_pretty(&meta).context("could not serialize metadata")?,
|
serde_json::to_vec_pretty(&meta).context("could not serialize metadata")?,
|
||||||
|
|||||||
Reference in New Issue
Block a user