Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_plugin and is_plugin is not used anymore in the code base #1240

Merged
merged 1 commit into from
Aug 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 1 addition & 36 deletions packages/core/src/lib/plugin_manager.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,8 @@
'use strict';

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

const pluginMatcher = /^plugin-(.*)$/;

/**
* Loads a plugin
*
* @param modulePath {string} the path to the plugin
* @return {object} the loaded plugin
*/
function loadPlugin(modulePath) {
return require(modulePath);
}

/**
* Given a path: return the plugin name if the path points to a valid plugin
* module directory, or false if it doesn't.
* @param filePath
* @returns Plugin name if exists or FALSE
*/
function isPlugin(filePath) {
const baseName = path.basename(filePath);
const pluginMatch = baseName.match(pluginMatcher);

if (pluginMatch) {
return pluginMatch[1];
}
return false;
}

/**
* Looks for installed plugins, loads them, and invokes them
* @param {object} patternlab
Expand All @@ -41,7 +12,7 @@ const plugin_manager = function() {
foundPlugins.forEach(plugin => {
logger.info(`Found plugin: ${plugin}`);
logger.info(`Attempting to load and initialize plugin.`);
const pluginModule = loadPlugin(plugin);
const pluginModule = require(plugin);
pluginModule(patternlab);
});
}
Expand All @@ -61,12 +32,6 @@ const plugin_manager = function() {
intialize_plugins: patternlab => {
initializePlugins(patternlab);
},
load_plugin: modulePath => {
return loadPlugin(modulePath);
},
is_plugin: filePath => {
return isPlugin(filePath);
},
raiseEvent: async (patternlab, eventName, ...args) => {
await raiseEvent(patternlab, eventName, args);
},
Expand Down