Skip to content

Commit

Permalink
feat: Throw error on duplicated plugin definition
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Duplicate plugin definition in configuration will now result
in an error instead of a warning.
  • Loading branch information
pgrzesik authored and medikoo committed Jan 27, 2022
1 parent b7d48e5 commit d3aca0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/classes/PluginManager.js
Expand Up @@ -115,11 +115,10 @@ class PluginManager {

// don't load plugins twice
if (this.plugins.some((plugin) => plugin instanceof Plugin)) {
this.serverless._logDeprecation(
'DUPLICATE_PLUGIN_DEFINITION',
'Starting with "v3.0.0", duplicate plugin definition will result in an error instead of a warning. To ensure seamless upgrade, please remove duplicate plugins from your configuration.'
throw new ServerlessError(
'Encountered duplicate plugin definition. Please remove duplicate plugins from your configuration.',
'DUPLICATE_PLUGIN_DEFINITION'
);
return null;
}

this.loadCommands(pluginInstance);
Expand Down
12 changes: 12 additions & 0 deletions test/unit/lib/classes/PluginManager.test.js
Expand Up @@ -1937,4 +1937,16 @@ describe('test/unit/lib/classes/PluginManager.test.js', () => {
expect(typeof plugin.utils.progress.create).to.equal('function');
expect(typeof plugin.utils.writeText).to.equal('function');
});

it('should error out for duplicate plugin definiton', async () => {
await expect(
runServerless({
fixture: 'plugin',
command: 'print',
configExt: {
plugins: ['./plugin', './plugin'],
},
})
).to.be.eventually.rejected.and.have.property('code', 'DUPLICATE_PLUGIN_DEFINITION');
});
});

0 comments on commit d3aca0a

Please sign in to comment.