mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Add init scripts as relevant paths to all directories.
This doesn't feel ideal. Though it's true that all directories are influenced by any init scripts they have, the directory middleware shouldn't need to know about Lua. I don't really want to go back into working on the middleware chain since it mostly feels like busywork when there are other things to build on in Rojo. also all of this feels really complicated
This commit is contained in:
parent
715022def5
commit
246fd5f6c4
10 changed files with 76 additions and 1 deletions
|
|
@ -47,11 +47,22 @@ impl SnapshotMiddleware for SnapshotDir {
|
|||
|
||||
let meta_path = entry.path().join("init.meta.json");
|
||||
|
||||
let relevant_paths = vec![
|
||||
entry.path().to_path_buf(),
|
||||
meta_path.clone(),
|
||||
// TODO: We shouldn't need to know about Lua existing in this
|
||||
// middleware. Should we figure out a way for that function to add
|
||||
// relevant paths to this middleware?
|
||||
entry.path().join("init.lua"),
|
||||
entry.path().join("init.server.lua"),
|
||||
entry.path().join("init.client.lua"),
|
||||
];
|
||||
|
||||
let mut snapshot = InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: InstanceMetadata {
|
||||
instigating_source: Some(entry.path().to_path_buf().into()),
|
||||
relevant_paths: vec![entry.path().to_path_buf(), meta_path.clone()],
|
||||
relevant_paths,
|
||||
..Default::default()
|
||||
},
|
||||
name: Cow::Owned(instance_name),
|
||||
|
|
|
|||
|
|
@ -204,6 +204,24 @@ mod test {
|
|||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_module_from_vfs() {
|
||||
let mut vfs = Vfs::new(NoopFetcher);
|
||||
let dir = VfsSnapshot::dir(hashmap! {
|
||||
"init.lua" => VfsSnapshot::file("Hello!"),
|
||||
});
|
||||
|
||||
vfs.debug_load_snapshot("/root", dir);
|
||||
|
||||
let entry = vfs.get("/root").unwrap();
|
||||
let instance_snapshot =
|
||||
SnapshotLua::from_vfs(&mut InstanceSnapshotContext::default(), &mut vfs, &entry)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn module_with_meta() {
|
||||
let mut vfs = Vfs::new(NoopFetcher);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /foo
|
||||
- /foo/init.meta.json
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /foo
|
||||
- /foo/init.meta.json
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
|
@ -22,6 +25,9 @@ children:
|
|||
relevant_paths:
|
||||
- /foo/Child
|
||||
- /foo/Child/init.meta.json
|
||||
- /foo/Child/init.lua
|
||||
- /foo/Child/init.server.lua
|
||||
- /foo/Child/init.client.lua
|
||||
name: Child
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
source: src/snapshot_middleware/lua.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
instigating_source:
|
||||
Path: /root
|
||||
relevant_paths:
|
||||
- /root
|
||||
- /root/init.meta.json
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
name: root
|
||||
class_name: ModuleScript
|
||||
properties:
|
||||
Source:
|
||||
Type: String
|
||||
Value: Hello!
|
||||
children: []
|
||||
|
|
@ -13,6 +13,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /root
|
||||
- /root/init.meta.json
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /root
|
||||
- /root/init.meta.json
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
|
|
|
|||
|
|
@ -13,4 +13,7 @@ metadata:
|
|||
relevant_paths:
|
||||
- /foo
|
||||
- /foo/init.meta.json
|
||||
- /foo/init.lua
|
||||
- /foo/init.server.lua
|
||||
- /foo/init.client.lua
|
||||
children: []
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /foo/src
|
||||
- /foo/src/init.meta.json
|
||||
- /foo/src/init.lua
|
||||
- /foo/src/init.server.lua
|
||||
- /foo/src/init.client.lua
|
||||
- /foo/default.project.json
|
||||
children:
|
||||
- id: id-2
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ metadata:
|
|||
relevant_paths:
|
||||
- /root
|
||||
- /root/init.meta.json
|
||||
- /root/init.lua
|
||||
- /root/init.server.lua
|
||||
- /root/init.client.lua
|
||||
children:
|
||||
- id: id-2
|
||||
name: test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue