Skip to content

Commit

Permalink
WIP loading plugin as part of #432
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Sep 8, 2016
1 parent e033370 commit 4c3c290
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
27 changes: 21 additions & 6 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* patternlab-node - v2.4.4 - 2016
*
/*
* patternlab-node - v2.4.4 - 2016
*
* Brian Muenzenmeyer, Geoff Pursell, and the web community.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
* Licensed under the MIT license.
*
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
*
*/

Expand Down Expand Up @@ -84,12 +84,14 @@ var patternlab_engine = function (config) {
lh = require('./lineage_hunter'),
ui = require('./ui_builder'),
sm = require('./starterkit_manager'),
pm = require('./plugin_manager'),
patternlab = {};

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

checkConfiguration(patternlab);
initializePlugins(patternlab);

var paths = patternlab.config.paths;

Expand Down Expand Up @@ -170,6 +172,19 @@ var patternlab_engine = function (config) {
}
}

function initializePlugins(patternlab) {
var plugin_manager = new pm(patternlab.config, path.resolve(__dirname, '../../patternlab-config.json'));
var foundPlugins = plugin_manager.detect_plugins();

if (foundPlugins && foundPlugins.length > 0) {

for (var i = 0; i < foundPlugins.length; i++) {
var plugin = plugin_manager.load_plugin(foundPlugins[i]);
plugin(patternlab);
}
}
}

function setCacheBust() {
if (patternlab.config.cacheBust) {
if (patternlab.config.debug) {
Expand Down
2 changes: 1 addition & 1 deletion core/lib/plugin_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var plugin_manager = function (config, configPath) {
installPlugin(pluginName);
},
load_plugin: function (pluginName) {
loadPlugin(pluginName);
return loadPlugin(pluginName);
},
detect_plugins: function () {
return detectPlugins();
Expand Down

0 comments on commit 4c3c290

Please # to comment.