Returns what commands are made available by addons by inspecting `includedCommands` for every addon. @private @method addonCommands @return {Object} Addon names and command maps as key-value pairs
()
| 448 | @return {Object} Addon names and command maps as key-value pairs |
| 449 | */ |
| 450 | addonCommands() { |
| 451 | const Command = require('../models/command'); |
| 452 | let commands = Object.create(null); |
| 453 | this.addons.forEach((addon) => { |
| 454 | if (!addon.includedCommands) { |
| 455 | return; |
| 456 | } |
| 457 | |
| 458 | let token = heimdall.start({ |
| 459 | name: `lookup-commands: ${addon.name}`, |
| 460 | addonName: addon.name, |
| 461 | addonCommandInitialization: true, |
| 462 | }); |
| 463 | |
| 464 | let includedCommands = addon.includedCommands(); |
| 465 | let addonCommands = Object.create(null); |
| 466 | |
| 467 | for (let key in includedCommands) { |
| 468 | if (typeof includedCommands[key] === 'function') { |
| 469 | addonCommands[key] = includedCommands[key]; |
| 470 | } else { |
| 471 | addonCommands[key] = Command.extend(includedCommands[key]); |
| 472 | } |
| 473 | } |
| 474 | if (Object.keys(addonCommands).length) { |
| 475 | commands[addon.name] = addonCommands; |
| 476 | } |
| 477 | |
| 478 | token.stop(); |
| 479 | }); |
| 480 | return commands; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | Execute a given callback for every addon command. |
no test coverage detected