box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
228 stars 59 forks source link

fix: Fix bulk action in `search` command #528

Closed arjankowski closed 7 months ago

coveralls commented 7 months ago

Pull Request Test Coverage Report for Build 8523388514

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/commands/search.js 4 5 80.0%
<!-- Total: 4 5 80.0% -->
Totals Coverage Status
Change from base Build 8171494392: 0.02%
Covered Lines: 4199
Relevant Lines: 4697

💛 - Coveralls
arjankowski commented 7 months ago

The SearchCommand was not working correctly when executing bulk actions, whereas it worked fine for single executions.

When executing a bulk command, parameters are prepared separately for each data row, and for this purpose, the _addFlagToArgv function from box-command.js is called. In its logic, this function checks the type of the passed argument, this.constructor.flags[flag].type === 'boolean'. For it to work correctly, the checked flag must be added to the flag list of the given command. However, in our case, SearchCommand.flags did not have the max-items flag, which is added manually into the body of the run function, and that's why we were getting the error:

TypeError: Cannot read property 'type' of undefined

To fix this, I've added the max-items flag to the SearchCommand so that the existing mechanism would work correctly. However, I set this flag to hidden so that it is not visible to the user.