Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more flexible plugin naming #469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/models/plugin-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ module.exports = CoreObject.extend({
},

_pluginName: function(addon) {
var pluginNameRegex = /^(ember\-cli\-deploy\-)(.*)$/;
return addon.name.match(pluginNameRegex)[2];
if(addon.name.indexOf('ember-cli-deploy') > -1) {
var pluginNameRegex = /^(ember\-cli\-deploy\-)(.*)$/;
return addon.name.match(pluginNameRegex)[2];
}
return addon.name;
},

_addonHasKeyword: function(addon, keyword) {
Expand Down
20 changes: 20 additions & 0 deletions node-tests/unit/models/plugin-registry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ describe('Plugin Registry', function() {
expect(logOutput[3]).to.eq('Visit http://ember-cli-deploy.com/plugins/ for a list of supported plugins.');
});

it('accepts plugins with names not starting with ember-cli-deploy and renames those starting with', function() {
var validPlugin = makePlugin('foo');
var otherNamedPlugin = makePlugin('bar');
otherNamedPlugin.name = 'my-other-bar';

var project = {
name: function() {return 'test-project';},
root: process.cwd(),
addons: [validPlugin, otherNamedPlugin],
};

var registry = new PluginRegistry(project, mockUi, {});

var plugins = registry.pluginInstances();

expect(plugins.length).to.equal(2);
expect(plugins[0].name).to.equal('foo');
expect(plugins[1].name).to.equal('my-other-bar');
});

it('returns plugins for addons that have the correct keyword and implement the plugin function', function() {
var validPlugin = makePlugin('foo');
var addonMissingKeyword = makeAddon('bar');
Expand Down