Skip to content

Commit

Permalink
feat(CLI): Introduce deprecation for duplicate plugin definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Oct 15, 2021
1 parent 4da0899 commit d2a75ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 8 additions & 0 deletions docs/deprecations.md
Expand Up @@ -36,6 +36,14 @@ Note:
- In service configuration setting is ineffective for deprecations reported before service configuration is read.
- `SLS_DEPRECATION_DISABLE` env var and `disabledDeprecations` configuration setting remain respected, and no errors will be thrown for mentioned deprecation coodes.

<a name="DUPLICATE_PLUGIN_DEFINITION"><div>&nbsp;</div></a>

## Duplicate plugin definition in configuration

Deprecation code: `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.

<a name="CLI_VERBOSE_OPTION_ALIAS"><div>&nbsp;</div></a>

## CLI `-v` alias for `--verbose` option
Expand Down
6 changes: 3 additions & 3 deletions lib/classes/PluginManager.js
Expand Up @@ -133,9 +133,9 @@ class PluginManager {

// don't load plugins twice
if (this.plugins.some((plugin) => plugin instanceof Plugin)) {
legacy.log(`WARNING: duplicate plugin ${Plugin.name} was not loaded\n`);
log.warning(
`Duplicate plugin definition found in your configuration. Plugin "${Plugin.name}" will not be loaded more than once.`
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.'
);
return null;
}
Expand Down
8 changes: 0 additions & 8 deletions test/unit/lib/classes/PluginManager.test.js
Expand Up @@ -568,14 +568,6 @@ describe('PluginManager', () => {
expect(pluginManager.plugins[0]).to.be.instanceof(SynchronousPluginMock);
});

it('should not load plugins twice', () => {
pluginManager.addPlugin(SynchronousPluginMock);
pluginManager.addPlugin(SynchronousPluginMock);

expect(pluginManager.plugins[0]).to.be.instanceof(SynchronousPluginMock);
expect(pluginManager.plugins.length).to.equal(1);
});

it('should load two plugins that happen to have the same class name', () => {
function getFirst() {
return class PluginMock {};
Expand Down

0 comments on commit d2a75ea

Please sign in to comment.