diff options
| author | Agando <roduccomm@gmail.com> | 2026-07-02 06:00:40 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-07-02 06:00:40 +0200 |
| commit | ea4d09fb5ccba12ed774fcf7c913edfa1e6a851a (patch) | |
| tree | 2361e33e52cdb4e0880ed0c776ed75943b37d7cf /modules/core/module-modmgr.js | |
| parent | 8b3e3e4527772bf060984f98777a2cff8e88aa09 (diff) | |
auto: 2026-07-02_06:00 changes
Diffstat (limited to 'modules/core/module-modmgr.js')
| -rw-r--r-- | modules/core/module-modmgr.js | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/modules/core/module-modmgr.js b/modules/core/module-modmgr.js index ec8c384..8c39e04 100644 --- a/modules/core/module-modmgr.js +++ b/modules/core/module-modmgr.js @@ -338,22 +338,27 @@ this.terminal.print(`✅ Module '${name}' marked as unloaded (commands will not be available)`, 'success'); }; - // module-reload <name> — unload + reload with diff - this.commands['module-reload'] = (args) => { + // module-reload <name> — re-fetch, re-parse, re-register + this.commands['module-reload'] = async (args) => { if (!args[0]) return this.terminal.print('Usage: module-reload <name>', 'warning'); const name = args[0]; const mod = this._getMod(name); if (!mod) return this.terminal.print(`Module not found: ${name}`, 'error'); - const wasLoaded = mod.loaded !== false; - const wasLazy = mod.lazy; - this.terminal.print(`🔄 Reloading '${name}' (was: ${wasLoaded ? 'loaded' : 'unloaded'}, lazy=${wasLazy})`, 'info'); - mod.loaded = false; - setTimeout(() => { - mod.loaded = true; - this.terminal.print(`✅ Module '${name}' reloaded`, 'success'); - const cmdCount = mod.commands ? Object.keys(mod.commands).length : 0; - this.terminal.print(` Now: loaded=true, lazy=${mod.lazy}, ${cmdCount} commands`, 'info'); - }, 100); + const mm = this.terminal.moduleManager; + // Find the module's URL from registry + const regEntry = mm.moduleRegistry.find(m => m.name === name); + const url = regEntry ? regEntry.url : null; + if (!url) return this.terminal.print(`Module '${name}' has no URL — cannot reload (built-in)`, 'warning'); + this.terminal.print(`🔄 Reloading '${name}' from ${url}...`, 'info'); + // Unregister old instance + mm.unregisterModule(name); + // Re-fetch and re-register + const success = await mm.loadModuleFromURL(url); + if (success) { + this.terminal.print(`✅ Module '${name}' reloaded successfully`, 'success'); + } else { + this.terminal.print(`❌ Failed to reload '${name}'`, 'error'); + } }; // module-reset <name> — clear module state and reload |