Merge pull request #4160 from patrickheeney/custom-cli

Allow custom CLI class instances
This commit is contained in:
Eslam λ Hefnawy 2017-08-28 20:40:14 +07:00 committed by GitHub
commit 184f99ff2e
2 changed files with 9 additions and 1 deletions

View File

@ -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();

View File

@ -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', () => {