mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Fix plugins are loaded twice bug
This commit is contained in:
parent
11fcea1331
commit
4630f02f2f
@ -129,13 +129,15 @@ class PluginManager {
|
||||
}
|
||||
|
||||
addPlugin(Plugin) {
|
||||
this.loadCommands(Plugin);
|
||||
const pluginInstance = new Plugin(this.serverless, this.cliOptions);
|
||||
|
||||
this.loadCommands(pluginInstance);
|
||||
|
||||
// shortcuts should be converted into options so that the plugin
|
||||
// author can use the option (instead of the shortcut)
|
||||
this.convertShortcutsIntoOptions(this.cliOptions, this.commands);
|
||||
|
||||
this.plugins.push(new Plugin(this.serverless, this.cliOptions));
|
||||
this.plugins.push(pluginInstance);
|
||||
}
|
||||
|
||||
loadCorePlugins() {
|
||||
@ -172,8 +174,8 @@ class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
loadCommands(Plugin) {
|
||||
this.commandsList.push((new Plugin(this.serverless)).commands);
|
||||
loadCommands(pluginInstance) {
|
||||
this.commandsList.push(pluginInstance.commands);
|
||||
|
||||
// TODO: refactor ASAP as it slows down overall performance
|
||||
// rebuild the commands
|
||||
|
||||
@ -410,7 +410,8 @@ describe('PluginManager', () => {
|
||||
|
||||
describe('#loadCommands()', () => {
|
||||
it('should load the plugin commands', () => {
|
||||
pluginManager.loadCommands(SynchronousPluginMock);
|
||||
const synchronousPluginMockInstance = new SynchronousPluginMock();
|
||||
pluginManager.loadCommands(synchronousPluginMockInstance);
|
||||
|
||||
expect(pluginManager.commandsList[0]).to.have.property('deploy');
|
||||
});
|
||||
@ -418,7 +419,8 @@ describe('PluginManager', () => {
|
||||
|
||||
describe('#getEvents()', () => {
|
||||
beforeEach(() => {
|
||||
pluginManager.loadCommands(SynchronousPluginMock);
|
||||
const synchronousPluginMockInstance = new SynchronousPluginMock();
|
||||
pluginManager.loadCommands(synchronousPluginMockInstance);
|
||||
});
|
||||
|
||||
it('should get all the matching events for a root level command in the correct order', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user