Refresh instead of reload and remove debug

This commit is contained in:
Jiiks 2018-01-21 01:38:57 +02:00
parent 8b9d923ae2
commit fe29c78583
2 changed files with 27 additions and 2 deletions

View File

@ -62,7 +62,6 @@ class PluginManager extends Module {
}
async loadAllPlugins() {
console.log("LOAD ALL PLUGINS!");
try {
const directories = await FileUtils.readDir(this.pluginsPath);
@ -81,6 +80,32 @@ class PluginManager extends Module {
}
}
async refreshPlugins() {
if (this.plugins.length <= 0) return this.loadAllPlugins();
try {
const directories = await FileUtils.readDir(this.pluginsPath);
for (let dir of directories) {
//If a plugin is already loaded this should resolve.
if (this.getPluginByDirName(dir)) continue;
try {
//Load the plugin if not
await this.loadPlugin(dir);
} catch (err) {
//We don't want every plugin to fail loading when one does
Logger.err('PluginManager', err);
}
}
for (let plugin of this.plugins) {
if (directories.includes(plugin.dirName)) continue;
//Plugin was deleted manually, stop it and remove any reference
}
} catch (err) {
throw err;
}
}
async loadPlugin(pluginPath) {
const { plugins } = this.state;
const dirName = pluginPath;

View File

@ -12,7 +12,7 @@
/*Methods*/
async function refreshLocalPlugins() {
try {
await PluginManager.loadAllPlugins();
await PluginManager.refreshPlugins();
} catch (err) {
}