Skip to content

Commit

Permalink
fix(command): use command.opts() over command._events
Browse files Browse the repository at this point in the history
command._events is a hidden property, which got changed recently, instead use command.opts() which
returns the right values

Closes #604
  • Loading branch information
thetutlage committed Jul 11, 2017
1 parent 8d0ffda commit da5e4e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Command/index.js
Expand Up @@ -63,14 +63,14 @@ class Command {
const self = this
const args = _.toArray(arguments)
const paramsLength = this.args.length
const commandOptions = args[paramsLength]
const commandOptions = args[args.length - 1]
const params = {}
const options = {}
_.each(_.take(args, paramsLength), (value, index) => {
params[this.args[index].name] = value || null
})
_.each(commandOptions._events, (option, name) => {
options[name] = commandOptions[name] || commandOptions[_.camelCase(name)] || null
_.each(commandOptions.opts(), (option, name) => {
options[name] = commandOptions[name] || null
})
this.setup()
co(function * () {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/command.spec.js
Expand Up @@ -238,6 +238,6 @@ describe('Command', function () {
const controller = new ControllerGenerator()
controller.run('new', ['awesome-project'], {'skip-install': true})
expect(commandData.args).deep.equal({name: 'awesome-project'})
expect(commandData.options).deep.equal({'skip-install': true})
expect(commandData.options).deep.equal({skipInstall: true})
})
})

0 comments on commit da5e4e8

Please sign in to comment.