mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Add handle_file_change to plugin API
This solves the problem I was running into with the ScriptPlugin implementation -- if foo/init.lua changes, foo needs to be requested, not 'foo/init.lua' (which would then erroneously create a ModuleScript before this commit)
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
use rbx::RbxItem;
|
||||
use vfs::VfsItem;
|
||||
use core::Route;
|
||||
|
||||
pub enum PluginResult {
|
||||
pub enum TransformResult {
|
||||
Value(Option<RbxItem>),
|
||||
Pass,
|
||||
}
|
||||
|
||||
pub enum FileChangeResult {
|
||||
MarkChanged(Option<Vec<Route>>),
|
||||
Pass,
|
||||
}
|
||||
|
||||
pub trait Plugin {
|
||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> PluginResult;
|
||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> TransformResult;
|
||||
fn handle_file_change(&self, route: &Route) -> FileChangeResult;
|
||||
}
|
||||
|
||||
pub struct PluginChain {
|
||||
@@ -24,8 +31,8 @@ impl PluginChain {
|
||||
pub fn transform_file(&self, vfs_item: &VfsItem) -> Option<RbxItem> {
|
||||
for plugin in &self.plugins {
|
||||
match plugin.transform_file(self, vfs_item) {
|
||||
PluginResult::Value(rbx_item) => return rbx_item,
|
||||
PluginResult::Pass => {},
|
||||
TransformResult::Value(rbx_item) => return rbx_item,
|
||||
TransformResult::Pass => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user