Skip to content

Commit

Permalink
fix(CLI): Fix handling of command options in help display
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 5, 2020
1 parent c0a2ecf commit 2fffb16
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/classes/CLI.js
Expand Up @@ -149,7 +149,7 @@ class CLI {
shortcut: 'c',
},
})
: commandObject.options;
: Object.assign({}, commandObject.options);

Object.entries(commandOptions).forEach(([option, optionsObject]) => {
let optionsDots = '.'.repeat(Math.max(dotsLength - option.length, 0));
Expand Down
8 changes: 8 additions & 0 deletions lib/classes/CLI.test.js
Expand Up @@ -697,4 +697,12 @@ describe('CLI [new tests]', () => {
.then(({ stdoutData }) => {
expect(stdoutData).to.not.include('Framework Core: ');
}));

it('Should handle incomplete command configurations', async () => {
const { stdoutData } = await runServerless({
fixture: 'plugin',
cliArgs: ['customCommand', '--help'],
});
expect(stdoutData).to.include('Description of custom command');
});
});
12 changes: 12 additions & 0 deletions test/fixtures/plugin/plugin.js
@@ -0,0 +1,12 @@
'use strict';

module.exports = class Plugin {
constructor() {
this.commands = {
customCommand: {
usage: 'Description of custom command',
configDependent: false,
},
};
}
};
10 changes: 10 additions & 0 deletions test/fixtures/plugin/serverless.yml
@@ -0,0 +1,10 @@
service: service

configValidationMode: error
frameworkVersion: '*'

provider:
name: aws

plugins:
- ./plugin

0 comments on commit 2fffb16

Please sign in to comment.