diff --git a/index.js b/index.js index d9719ae4588ce7ed78b2f3dae13133915048ae81..2844ffae0fdd895d42b5849dadac0a64c5fb2473 100644 --- a/index.js +++ b/index.js @@ -190,5 +190,18 @@ function listPlugins(conditionTest) { } } catch (e) {} } + // Special: self dependency (if local package is also a module) + if (pkgJSON.main) { + const dep = pkgJSON.name + const required = require(path.resolve('./' + pkgJSON.main)) + if (required && conditionTest(required)) { + uiDependencies.push({ + name: dep, + version: 'local', + locked: true, + required + }) + } + } return uiDependencies } diff --git a/server/controller/webmin.js b/server/controller/webmin.js index 0f29e2d36664ba85ffb8dcb694f544351518438d..268bf23137a55b47c4b9bc87b3973665ac24ee1e 100644 --- a/server/controller/webmin.js +++ b/server/controller/webmin.js @@ -580,8 +580,13 @@ function WebAdmin (duniterServer, startServices, stopServices, listDuniterUIPlug this.plugUiModulesGetInjection = (req) => co(function*() { const module = req.params.package - const required = require(module) - return required.duniterUI.inject || {} + const plugins = listDuniterUIPlugins() + for (const plugin of plugins) { + if (plugin.name === module) { + return plugin.required.duniterUI.inject || {} + } + } + return {} }) this.plugCheckAccess = (req) => requirePlugin().duniter.methods.canWrite()