Correctly unload plugin paths

pull/5840/head
Chocobozzz 2023-06-06 11:59:27 +02:00
parent 25d7cc3cb6
commit 07880c3642
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 6 additions and 6 deletions

View File

@ -3,16 +3,16 @@
import { extname } from 'path' import { extname } from 'path'
function decachePlugin (pluginPath: string, libraryPath: string) { function decachePlugin (libraryPath: string) {
const moduleName = find(libraryPath) const moduleName = find(libraryPath)
if (!moduleName) return if (!moduleName) return
searchCache(moduleName, function (mod) { searchCache(moduleName, function (mod) {
delete require.cache[mod.id] delete require.cache[mod.id]
})
removeCachedPath(pluginPath) removeCachedPath(mod.path)
})
} }
function decacheModule (name: string) { function decacheModule (name: string) {
@ -22,9 +22,9 @@ function decacheModule (name: string) {
searchCache(moduleName, function (mod) { searchCache(moduleName, function (mod) {
delete require.cache[mod.id] delete require.cache[mod.id]
})
removeCachedPath(moduleName) removeCachedPath(mod.path)
})
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@ -496,7 +496,7 @@ export class PluginManager implements ServerHook {
// Delete cache if needed // Delete cache if needed
const modulePath = join(pluginPath, packageJSON.library) const modulePath = join(pluginPath, packageJSON.library)
decachePlugin(pluginPath, modulePath) decachePlugin(modulePath)
const library: PluginLibrary = require(modulePath) const library: PluginLibrary = require(modulePath)
if (!isLibraryCodeValid(library)) { if (!isLibraryCodeValid(library)) {