Skip to content

Commit fe7351c

Browse files
committed
fix(core): find plugins from config only and with simpler args
1 parent ae0d91a commit fe7351c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

packages/core/src/lib/plugin_manager.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
const plugin_manager = function() {
3+
const plugin_manager = function () {
44
const path = require('path');
5-
const findModules = require('./findModules');
65
const logger = require('./log');
76

87
const pluginMatcher = /^plugin-(.*)$/;
@@ -38,20 +37,18 @@ const plugin_manager = function() {
3837
* @param {object} patternlab
3938
*/
4039
function initializePlugins(patternlab) {
41-
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
42-
const foundPlugins = findModules(nodeModulesPath, isPlugin);
40+
const foundPlugins = Object.keys(patternlab.config.plugins || {})
4341
foundPlugins.forEach(plugin => {
44-
logger.info(`Found plugin: plugin-${plugin.name}`);
42+
logger.info(`Found plugin: ${plugin}`);
4543
logger.info(`Attempting to load and initialize plugin.`);
46-
const pluginModule = loadPlugin(plugin.modulePath);
44+
const pluginModule = loadPlugin(path.join(process.cwd(), 'node_modules', plugin));
4745
pluginModule(patternlab);
4846
});
4947
}
5048

51-
async function raiseEvent(patternlab, eventName, ...args) {
49+
async function raiseEvent(patternlab, eventName, args) {
5250
patternlab.events.emit(eventName, args);
53-
54-
await (async function() {
51+
await (async function () {
5552
const hookHandlers = (patternlab.hooks[eventName] || []).map(h =>
5653
h(args)
5754
);

0 commit comments

Comments
 (0)