Skip to content

Commit

Permalink
fix(core): find plugins from config only and with simpler args
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Oct 15, 2019
1 parent ae0d91a commit fe7351c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/core/src/lib/plugin_manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

const plugin_manager = function() {
const plugin_manager = function () {
const path = require('path');
const findModules = require('./findModules');
const logger = require('./log');

const pluginMatcher = /^plugin-(.*)$/;
Expand Down Expand Up @@ -38,20 +37,18 @@ const plugin_manager = function() {
* @param {object} patternlab
*/
function initializePlugins(patternlab) {
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
const foundPlugins = findModules(nodeModulesPath, isPlugin);
const foundPlugins = Object.keys(patternlab.config.plugins || {})
foundPlugins.forEach(plugin => {
logger.info(`Found plugin: plugin-${plugin.name}`);
logger.info(`Found plugin: ${plugin}`);
logger.info(`Attempting to load and initialize plugin.`);
const pluginModule = loadPlugin(plugin.modulePath);
const pluginModule = loadPlugin(path.join(process.cwd(), 'node_modules', plugin));
pluginModule(patternlab);
});
}

async function raiseEvent(patternlab, eventName, ...args) {
async function raiseEvent(patternlab, eventName, args) {
patternlab.events.emit(eventName, args);

await (async function() {
await (async function () {
const hookHandlers = (patternlab.hooks[eventName] || []).map(h =>
h(args)
);
Expand Down

0 comments on commit fe7351c

Please sign in to comment.