diff --git a/lib/Serverless.js b/lib/Serverless.js index 6ce957ab8..197d5e055 100644 --- a/lib/Serverless.js +++ b/lib/Serverless.js @@ -49,7 +49,7 @@ class Serverless { init() { // create a new CLI instance - this.cli = new CLI(this); + this.cli = new this.classes.CLI(this); // get an array of commands and options that should be processed this.processedInput = this.cli.processInput(); diff --git a/lib/Serverless.test.js b/lib/Serverless.test.js index b33836407..830df7220 100644 --- a/lib/Serverless.test.js +++ b/lib/Serverless.test.js @@ -115,6 +115,14 @@ describe('Serverless', () => { expect(serverless.cli).to.be.instanceof(CLI); }); + it('should allow a custom CLI instance', () => { + class CustomCLI extends CLI {} + serverless.classes.CLI = CustomCLI; + serverless.init(); + expect(serverless.cli).to.be.instanceof(CLI); + expect(serverless.cli.constructor.name).to.equal('CustomCLI'); + }); + // note: we just test that the processedInput variable is set (not the content of it) // the test for the correct input is done in the CLI class test file it('should receive the processed input form the CLI instance', () => {