Well, I started working on a plugin distribution system using Gist, but I quickly realized that without some orchestration we’d eventually hit a wall. Either because each plugin would have to reimplement a lot of common functionality, or users would have to juggle the --priority: X comments in the imported pages.
So naturally the first step is to try to tame the dependencies. So I’ve spent a few hours today on implementation.
@zef I’ve also hit a weird Lua behavior in buildDependencyGraph() method.
When I try to register a plugin that has no dependencies field specified (not present) or define some dependencies (the table is not empty) then everything works as expected.
But when I define the empty dependencies = {} in the manifest, Lua fails to execute the code saying that dep is nil inside if dep.optional then here:
for _, dep in ipairs(plugin.manifest.dependencies or {}) do
if not dep.optional then
table.insert(graph[id], dep.id)
end
end
Here the plugin.manifest.dependencies is {} and of type table (I’ve checked that) but for some reason it descends into the for loop with dep set to nil, which causes the error.
Either the for loop or the empty dependency table is doing something shady here
EDIT: Right now I’ve “fixed” the problem in the latest revision by surrounding the loops with if #dependencies > 0.
You can get the code that has this problem previous revision: Plugin Dependency System.md · GitHub
I tried to replicate this behavior, but can’t seem to. I also imported Plugin Dependency System.md · GitHub and tried it by enabling the basic and plugin with dependencies examples (switching their code blocks from lua and space-lua) and it all seems to work fine. This is quite something elaborate you’re building here btw
Do you still see this problem, and can you somehow get to a minimal example of where this happens?