refactor: module reference
This commit is contained in:
parent
7ae927d78a
commit
42a40934fa
|
@ -21,10 +21,12 @@ export default class Latus {
|
|||
this.config = config;
|
||||
this.originalConfig = JSON.parse(JSON.stringify(this.config));
|
||||
this.hooks = {};
|
||||
this.modules = {};
|
||||
const entries = Object.entries(modules);
|
||||
debug('latus paths: %O', entries.map(([plugin]) => plugin));
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [plugin, M] = entries[i];
|
||||
this.modules[plugin] = M;
|
||||
if (M.default) {
|
||||
const {default: {hooks}} = M;
|
||||
if (hooks) {
|
||||
|
@ -275,6 +277,10 @@ export default class Latus {
|
|||
});
|
||||
}
|
||||
|
||||
module(path) {
|
||||
return this.modules[path];
|
||||
}
|
||||
|
||||
refresh(plugin, M) {
|
||||
const keys = Object.keys(this.hooks);
|
||||
for (let j = 0; j < keys.length; j++) {
|
||||
|
@ -286,6 +292,7 @@ export default class Latus {
|
|||
}
|
||||
}
|
||||
}
|
||||
this.modules[plugin] = M;
|
||||
if (M.default) {
|
||||
const {default: {hooks}} = M;
|
||||
if (hooks) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user