Skip to content
Snippets Groups Projects
Commit d34148ad authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] #918 Also inject local plugin if it exists

parent 249644e1
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment