fix: plugin dependencies not enabling (#150)

This commit is contained in:
megumin 2022-10-23 19:09:02 +01:00 committed by GitHub
parent ff9d904fcb
commit ffbb52512c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 114 additions and 18 deletions

View file

@ -42,6 +42,26 @@ export function startAllPlugins() {
}
}
export function startDependenciesRecursive(p: Plugin) {
let restartNeeded = false;
const failures: string[] = [];
if (p.dependencies) for (const dep of p.dependencies) {
if (!Settings.plugins[dep].enabled) {
startDependenciesRecursive(Plugins[dep]);
// If the plugin has patches, don't start the plugin, just enable it.
if (Plugins[dep].patches) {
logger.warn(`Enabling dependency ${dep} requires restart.`);
Settings.plugins[dep].enabled = true;
restartNeeded = true;
continue;
}
const result = startPlugin(Plugins[dep]);
if (!result) failures.push(dep);
}
}
return { restartNeeded, failures };
}
export function startPlugin(p: Plugin) {
if (p.start) {
logger.info("Starting plugin", p.name);