Skip to content

Commit

Permalink
bug: plugin components configuration incorrectly pass into plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ilfroloff committed Dec 21, 2017
1 parent 496231d commit a9bd549
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 5 additions & 1 deletion core/application/ComponentsBuilder.js
Expand Up @@ -83,8 +83,12 @@ ComponentsBuilder.prototype.build_component = function build_component(component
}

component_config.name = component_config.name || component.name;
component_config.config = _defaults(
component_config.config || {},
(this._components_configs[component_config.name])
);

component = new component(_defaults(component_config, this._components_configs[component_config.name]));
component = new component(component_config);
}

return component instanceof Component ?
Expand Down
10 changes: 10 additions & 0 deletions examples/plugins/config/plugins.js
@@ -0,0 +1,10 @@
module.exports = {
components: {
PluginComponent: {
key1: 'value1'
},
PluginClassComponent: {
key2: 'value2'
}
}
};
8 changes: 7 additions & 1 deletion test/plugins.js
Expand Up @@ -8,7 +8,8 @@ var IFNode = require('..');

var app = IFNode({
project_folder: Path.resolve(__dirname, '../examples/plugins'),
alias: 'plugins'
alias: 'plugins',
environment: 'plugins'
});

app.register([
Expand Down Expand Up @@ -47,4 +48,9 @@ describe('Plugins', function() {
app.component('PluginComponent')
);
});

it('should has correct configurations for plugins', function() {
Should.deepEqual(app.component('PluginComponent').config, app.config.components.PluginComponent);
Should.deepEqual(app.component('PluginClassComponent').config, app.config.components.PluginClassComponent);
});
});

0 comments on commit a9bd549

Please sign in to comment.