mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
fix the plugin commands bug
This commit is contained in:
parent
1fb90f6dc1
commit
355bfa01c0
@ -90,6 +90,9 @@ class PluginManager {
|
||||
|
||||
this.addPlugin(Plugin);
|
||||
} catch (error) {
|
||||
if (this.cliCommands[0] === 'plugin') {
|
||||
return;
|
||||
}
|
||||
let errorMessage;
|
||||
if (error && error.code === 'MODULE_NOT_FOUND' && error.message.endsWith(`'${plugin}'`)) {
|
||||
// Plugin not installed
|
||||
@ -135,7 +138,6 @@ class PluginManager {
|
||||
if (this.serverless && this.serverless.config && this.serverless.config.servicePath) {
|
||||
module.paths.unshift(path.join(this.serverless.config.servicePath, '.serverless_plugins'));
|
||||
}
|
||||
|
||||
this.loadPlugins(servicePlugins);
|
||||
}
|
||||
|
||||
|
||||
@ -665,6 +665,16 @@ describe('PluginManager', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should not throw error when running the plugin commands and given plugins does not exist',
|
||||
() => {
|
||||
const servicePlugins = ['ServicePluginMock3'];
|
||||
const cliCommandsMock = ['plugin'];
|
||||
pluginManager.setCliCommands(cliCommandsMock);
|
||||
|
||||
expect(() => pluginManager.loadPlugins(servicePlugins))
|
||||
.to.not.throw(serverless.classes.Error);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mockRequire.stop('ServicePluginMock1');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user