Skip to content

Commit 4c3c290

Browse files
committed
WIP loading plugin as part of #432
1 parent e033370 commit 4c3c290

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

core/lib/patternlab.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v2.4.4 - 2016
3-
*
1+
/*
2+
* patternlab-node - v2.4.4 - 2016
3+
*
44
* Brian Muenzenmeyer, Geoff Pursell, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

@@ -84,12 +84,14 @@ var patternlab_engine = function (config) {
8484
lh = require('./lineage_hunter'),
8585
ui = require('./ui_builder'),
8686
sm = require('./starterkit_manager'),
87+
pm = require('./plugin_manager'),
8788
patternlab = {};
8889

8990
patternlab.package = fs.readJSONSync(path.resolve(__dirname, '../../package.json'));
9091
patternlab.config = config || fs.readJSONSync(path.resolve(__dirname, '../../patternlab-config.json'));
9192

9293
checkConfiguration(patternlab);
94+
initializePlugins(patternlab);
9395

9496
var paths = patternlab.config.paths;
9597

@@ -170,6 +172,19 @@ var patternlab_engine = function (config) {
170172
}
171173
}
172174

175+
function initializePlugins(patternlab) {
176+
var plugin_manager = new pm(patternlab.config, path.resolve(__dirname, '../../patternlab-config.json'));
177+
var foundPlugins = plugin_manager.detect_plugins();
178+
179+
if (foundPlugins && foundPlugins.length > 0) {
180+
181+
for (var i = 0; i < foundPlugins.length; i++) {
182+
var plugin = plugin_manager.load_plugin(foundPlugins[i]);
183+
plugin(patternlab);
184+
}
185+
}
186+
}
187+
173188
function setCacheBust() {
174189
if (patternlab.config.cacheBust) {
175190
if (patternlab.config.debug) {

core/lib/plugin_manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var plugin_manager = function (config, configPath) {
5959
installPlugin(pluginName);
6060
},
6161
load_plugin: function (pluginName) {
62-
loadPlugin(pluginName);
62+
return loadPlugin(pluginName);
6363
},
6464
detect_plugins: function () {
6565
return detectPlugins();

0 commit comments

Comments
 (0)