Skip to content

Commit

Permalink
Merge pull request #535 from astronomersiva/master
Browse files Browse the repository at this point in the history
Fix plugin name extraction for scoped packages
  • Loading branch information
lukemelia committed Nov 10, 2022
2 parents f1b0358 + acf68db commit 2c1f455
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/models/plugin-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ module.exports = CoreObject.extend({

_pluginName: function(addon) {
if(addon.name.indexOf('ember-cli-deploy') > -1) {
var pluginNameRegex = /^(ember-cli-deploy-)(.*)$/;
return addon.name.match(pluginNameRegex)[2];
var pluginNameRegex = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?(ember-cli-deploy-)(.*)$/;
return addon.name.match(pluginNameRegex)[3];
}
return addon.name;
},
Expand Down
9 changes: 7 additions & 2 deletions node-tests/unit/models/plugin-registry-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,27 @@ describe('Plugin Registry', function() {

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 orgScopedPlugin = makePlugin('baz');
orgScopedPlugin.name = '@my-org/ember-cli-deploy-baz';

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

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

var plugins = registry.pluginInstances();

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

it('returns plugins for addons that have the correct keyword and implement the plugin function', function() {
Expand Down

0 comments on commit 2c1f455

Please sign in to comment.