|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -const plugin_manager = function() { |
| 3 | +const plugin_manager = function () { |
4 | 4 | const path = require('path');
|
5 |
| - const findModules = require('./findModules'); |
6 | 5 | const logger = require('./log');
|
7 | 6 |
|
8 | 7 | const pluginMatcher = /^plugin-(.*)$/;
|
@@ -38,20 +37,18 @@ const plugin_manager = function() {
|
38 | 37 | * @param {object} patternlab
|
39 | 38 | */
|
40 | 39 | 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 || {}) |
43 | 41 | foundPlugins.forEach(plugin => {
|
44 |
| - logger.info(`Found plugin: plugin-${plugin.name}`); |
| 42 | + logger.info(`Found plugin: ${plugin}`); |
45 | 43 | 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)); |
47 | 45 | pluginModule(patternlab);
|
48 | 46 | });
|
49 | 47 | }
|
50 | 48 |
|
51 |
| - async function raiseEvent(patternlab, eventName, ...args) { |
| 49 | + async function raiseEvent(patternlab, eventName, args) { |
52 | 50 | patternlab.events.emit(eventName, args);
|
53 |
| - |
54 |
| - await (async function() { |
| 51 | + await (async function () { |
55 | 52 | const hookHandlers = (patternlab.hooks[eventName] || []).map(h =>
|
56 | 53 | h(args)
|
57 | 54 | );
|
|
0 commit comments