From 42a40934fa5e4a57e49ec0ab93052b20613dbbe4 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 31 Mar 2021 10:33:45 -0500 Subject: [PATCH] refactor: module reference --- packages/core/src/latus.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/src/latus.js b/packages/core/src/latus.js index 7de01a0..3e0286f 100644 --- a/packages/core/src/latus.js +++ b/packages/core/src/latus.js @@ -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) {