Skip to content

Commit

Permalink
made some small improvements to plugin loading - which will move us t…
Browse files Browse the repository at this point in the history
…oward a better state
  • Loading branch information
bmuenzenmeyer committed Feb 9, 2017
1 parent f0fe98b commit 0b17382
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function checkConfiguration(patternlab) {
* Finds and calls the main method of any found plugins.
* @param patternlab - global data store
*/

//todo, move this to plugin_manager
function initializePlugins(patternlab) {

if (!patternlab.config.plugins) { return; }
Expand Down
23 changes: 19 additions & 4 deletions core/lib/plugin_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,25 @@ var plugin_manager = function (config, configPath) {
if (!diskConfig.plugins) {
diskConfig.plugins = {};
}
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false
};

if (!diskConfig.plugins[pluginName]) {
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false,
options: {}
};
}

const pluginPathConfig = path.resolve(pluginPath, 'config.json');
try {
var pluginConfigJSON = require(pluginPathConfig);
if (!diskConfig.plugins[pluginName].options) {

diskConfig.plugins[pluginName].options = pluginConfigJSON;
}
} catch (ex) {
//a config.json file is not required at this time
}

//write config entry back
fs.outputFileSync(path.resolve(configPath), JSON.stringify(diskConfig, null, 2));
Expand Down

0 comments on commit 0b17382

Please sign in to comment.