forked from rojo-rbx/rojo
Change each VfsItem to keep a full route instead of just its name
This commit is contained in:
@@ -19,7 +19,7 @@ impl DefaultPlugin {
|
||||
impl Plugin for DefaultPlugin {
|
||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult {
|
||||
match vfs_item {
|
||||
&VfsItem::File { ref contents, ref name } => {
|
||||
&VfsItem::File { ref contents, .. } => {
|
||||
let mut properties = HashMap::new();
|
||||
|
||||
properties.insert("Value".to_string(), RbxValue::String {
|
||||
@@ -27,13 +27,13 @@ impl Plugin for DefaultPlugin {
|
||||
});
|
||||
|
||||
TransformFileResult::Value(Some(RbxItem {
|
||||
name: name.clone(),
|
||||
name: vfs_item.name().clone(),
|
||||
class_name: "StringValue".to_string(),
|
||||
children: Vec::new(),
|
||||
properties,
|
||||
}))
|
||||
},
|
||||
&VfsItem::Dir { ref children, ref name } => {
|
||||
&VfsItem::Dir { ref children, .. } => {
|
||||
let mut rbx_children = Vec::new();
|
||||
|
||||
for (_, child_item) in children {
|
||||
@@ -46,7 +46,7 @@ impl Plugin for DefaultPlugin {
|
||||
}
|
||||
|
||||
TransformFileResult::Value(Some(RbxItem {
|
||||
name: name.clone(),
|
||||
name: vfs_item.name().clone(),
|
||||
class_name: "Folder".to_string(),
|
||||
children: rbx_children,
|
||||
properties: HashMap::new(),
|
||||
|
||||
@@ -21,8 +21,8 @@ impl JsonModelPlugin {
|
||||
impl Plugin for JsonModelPlugin {
|
||||
fn transform_file(&self, _plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult {
|
||||
match vfs_item {
|
||||
&VfsItem::File { ref contents, ref name } => {
|
||||
let rbx_name = match JSON_MODEL_PATTERN.captures(name) {
|
||||
&VfsItem::File { ref contents, .. } => {
|
||||
let rbx_name = match JSON_MODEL_PATTERN.captures(vfs_item.name()) {
|
||||
Some(captures) => captures.get(1).unwrap().as_str().to_string(),
|
||||
None => return TransformFileResult::Pass,
|
||||
};
|
||||
@@ -30,7 +30,7 @@ impl Plugin for JsonModelPlugin {
|
||||
let mut rbx_item: RbxItem = match serde_json::from_str(contents) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
eprintln!("Unable to parse JSON Model File named {}", name);
|
||||
eprintln!("Unable to parse JSON Model File named {}", vfs_item.name());
|
||||
|
||||
return TransformFileResult::Pass; // This should be an error in the future!
|
||||
},
|
||||
|
||||
@@ -28,7 +28,9 @@ impl ScriptPlugin {
|
||||
impl Plugin for ScriptPlugin {
|
||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformFileResult {
|
||||
match vfs_item {
|
||||
&VfsItem::File { ref contents, ref name } => {
|
||||
&VfsItem::File { ref contents, .. } => {
|
||||
let name = vfs_item.name();
|
||||
|
||||
let (class_name, rbx_name) = {
|
||||
if let Some(captures) = SERVER_PATTERN.captures(name) {
|
||||
("Script".to_string(), captures.get(1).unwrap().as_str().to_string())
|
||||
@@ -54,7 +56,7 @@ impl Plugin for ScriptPlugin {
|
||||
properties,
|
||||
}))
|
||||
},
|
||||
&VfsItem::Dir { ref children, ref name } => {
|
||||
&VfsItem::Dir { ref children, .. } => {
|
||||
let init_item = {
|
||||
let maybe_item = children.get(SERVER_INIT)
|
||||
.or(children.get(CLIENT_INIT))
|
||||
@@ -75,7 +77,7 @@ impl Plugin for ScriptPlugin {
|
||||
};
|
||||
|
||||
rbx_item.name.clear();
|
||||
rbx_item.name.push_str(name);
|
||||
rbx_item.name.push_str(vfs_item.name());
|
||||
|
||||
for (child_name, child_item) in children {
|
||||
if child_name == init_item.name() {
|
||||
|
||||
Reference in New Issue
Block a user