1
1
'use strict' ;
2
2
3
3
const plugin_manager = function ( ) {
4
- const path = require ( 'path' ) ;
5
4
const logger = require ( './log' ) ;
6
5
7
- const pluginMatcher = / ^ p l u g i n - ( .* ) $ / ;
8
-
9
- /**
10
- * Loads a plugin
11
- *
12
- * @param modulePath {string} the path to the plugin
13
- * @return {object } the loaded plugin
14
- */
15
- function loadPlugin ( modulePath ) {
16
- return require ( modulePath ) ;
17
- }
18
-
19
- /**
20
- * Given a path: return the plugin name if the path points to a valid plugin
21
- * module directory, or false if it doesn't.
22
- * @param filePath
23
- * @returns Plugin name if exists or FALSE
24
- */
25
- function isPlugin ( filePath ) {
26
- const baseName = path . basename ( filePath ) ;
27
- const pluginMatch = baseName . match ( pluginMatcher ) ;
28
-
29
- if ( pluginMatch ) {
30
- return pluginMatch [ 1 ] ;
31
- }
32
- return false ;
33
- }
34
-
35
6
/**
36
7
* Looks for installed plugins, loads them, and invokes them
37
8
* @param {object } patternlab
@@ -41,7 +12,7 @@ const plugin_manager = function() {
41
12
foundPlugins . forEach ( plugin => {
42
13
logger . info ( `Found plugin: ${ plugin } ` ) ;
43
14
logger . info ( `Attempting to load and initialize plugin.` ) ;
44
- const pluginModule = loadPlugin ( plugin ) ;
15
+ const pluginModule = require ( plugin ) ;
45
16
pluginModule ( patternlab ) ;
46
17
} ) ;
47
18
}
@@ -61,12 +32,6 @@ const plugin_manager = function() {
61
32
intialize_plugins : patternlab => {
62
33
initializePlugins ( patternlab ) ;
63
34
} ,
64
- load_plugin : modulePath => {
65
- return loadPlugin ( modulePath ) ;
66
- } ,
67
- is_plugin : filePath => {
68
- return isPlugin ( filePath ) ;
69
- } ,
70
35
raiseEvent : async ( patternlab , eventName , ...args ) => {
71
36
await raiseEvent ( patternlab , eventName , args ) ;
72
37
} ,
0 commit comments