Move unloading plugin main script to the plugin manager

This commit is contained in:
Samuel Elliott 2018-08-22 17:44:30 +01:00
parent 4bed9f726c
commit 42a89129d4
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
3 changed files with 6 additions and 6 deletions

View File

@ -307,7 +307,7 @@ export default class {
const index = this.getContentIndex(content);
delete Globals.require.cache[Globals.require.resolve(content.paths.mainPath)];
if (this.unloadContentHook) this.unloadContentHook(content);
if (reload) {
const newcontent = await this.preloadContent(content.dirName, true, index);

View File

@ -279,11 +279,7 @@ export default class PluginApi {
}
addModal(_modal, component) {
const modal = Modals.add(_modal, component);
modal.on('close', () => {
let index;
while ((index = this.modalStack.findIndex(m => m === modal)) > -1)
this.modalStack.splice(index, 1);
});
modal.on('close', () => Utils.removeFromArray(this.modalStack, modal));
this.modalStack.push(modal);
return modal;
}

View File

@ -128,6 +128,10 @@ export default class extends ContentManager {
static get unloadPlugin() { return this.unloadContent }
static get reloadPlugin() { return this.reloadContent }
static unloadContentHook(content, reload) {
delete Globals.require.cache[Globals.require.resolve(content.paths.mainPath)];
}
/**
* Stops a plugin.
* @param {Plugin|String} plugin