diff --git a/core/lib/patternlab.js b/core/lib/patternlab.js index 80785662c..8db95639f 100644 --- a/core/lib/patternlab.js +++ b/core/lib/patternlab.js @@ -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; } diff --git a/core/lib/plugin_manager.js b/core/lib/plugin_manager.js index 136cc7324..bcd9c6812 100644 --- a/core/lib/plugin_manager.js +++ b/core/lib/plugin_manager.js @@ -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));