forked from rojo-rbx/rojo
Starts work on #55. This is similar to the previous work in #125. It's gated behind a new Cargo feature, `user-plugins`. This time, the config gate is much smaller. The `plugins` member of projects is still accessible when plugins aren't enabled, but is always empty. Additionally, user plugins are only enabled if there's a Lua state present in the snapshot context when the `SnapshotUserPlugins` snapshot middleware runs. This not ever the case currently. This code has very little possibility of rotting while we focus on other work, since it'll be guaranteed to still compile and can be tested in isolation without the feature being turned on.
20 lines
415 B
Lua
20 lines
415 B
Lua
print("test-plugin initializing...")
|
|
|
|
return function(nextDispatch, entry)
|
|
if entry:isDirectory() then
|
|
return nextDispatch(entry)
|
|
end
|
|
|
|
local name = entry:fileName()
|
|
local instanceName = name:match("(.-)%.moon$")
|
|
|
|
if instanceName == nil then
|
|
return nextDispatch(entry)
|
|
end
|
|
|
|
return rojo.instance({
|
|
Name = instanceName,
|
|
ClassName = "ModuleScript",
|
|
Source = compileMoonScript(entry:contents()),
|
|
})
|
|
end |