feat(CLI): Introduce deprecation for duplicate plugin definition

This commit is contained in:
Piotr Grzesik 2021-10-15 09:29:56 +02:00
parent 4da0899673
commit d2a75ea95e
3 changed files with 11 additions and 11 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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 {};