forked from rojo-rbx/rojo
Attach context to instances produced by middleware (#273)
This commit is contained in:
committed by
GitHub
parent
f0a602b48b
commit
4b89bb087a
@@ -33,7 +33,7 @@ impl SnapshotMiddleware for SnapshotLua {
|
||||
}
|
||||
|
||||
if entry.is_file() {
|
||||
snapshot_lua_file(vfs, entry)
|
||||
snapshot_lua_file(context, vfs, entry)
|
||||
} else {
|
||||
// At this point, our entry is definitely a directory!
|
||||
|
||||
@@ -54,7 +54,11 @@ impl SnapshotMiddleware for SnapshotLua {
|
||||
}
|
||||
|
||||
/// Core routine for turning Lua files into snapshots.
|
||||
fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotInstanceResult {
|
||||
fn snapshot_lua_file<F: VfsFetcher>(
|
||||
context: &InstanceContext,
|
||||
vfs: &Vfs<F>,
|
||||
entry: &VfsEntry,
|
||||
) -> SnapshotInstanceResult {
|
||||
let file_name = entry.path().file_name().unwrap().to_string_lossy();
|
||||
|
||||
let (class_name, instance_name) = if let Some(name) = match_trailing(&file_name, ".server.lua")
|
||||
@@ -89,7 +93,8 @@ fn snapshot_lua_file<F: VfsFetcher>(vfs: &Vfs<F>, entry: &VfsEntry) -> SnapshotI
|
||||
.metadata(
|
||||
InstanceMetadata::new()
|
||||
.instigating_source(entry.path())
|
||||
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()]),
|
||||
.relevant_paths(vec![entry.path().to_path_buf(), meta_path.clone()])
|
||||
.context(context),
|
||||
);
|
||||
|
||||
if let Some(meta_entry) = vfs.get(meta_path).with_not_found()? {
|
||||
@@ -116,7 +121,7 @@ fn snapshot_init<F: VfsFetcher>(
|
||||
|
||||
if let Some(init_entry) = vfs.get(init_path).with_not_found()? {
|
||||
if let Some(dir_snapshot) = SnapshotDir::from_vfs(context, vfs, folder_entry)? {
|
||||
if let Some(mut init_snapshot) = snapshot_lua_file(vfs, &init_entry)? {
|
||||
if let Some(mut init_snapshot) = snapshot_lua_file(context, vfs, &init_entry)? {
|
||||
if dir_snapshot.class_name != "Folder" {
|
||||
panic!(
|
||||
"init.lua, init.server.lua, and init.client.lua can \
|
||||
|
||||
Reference in New Issue
Block a user