From ae61792d5b054067a6151a41ac2c30a52538d829 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 14 Dec 2018 09:12:29 -0500 Subject: [PATCH] change to isArray and fix history with length --- src/lib/core/plugin.js | 1 - src/lib/modules/console/index.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/core/plugin.js b/src/lib/core/plugin.js index f1c0342189..32cee7e1de 100644 --- a/src/lib/core/plugin.js +++ b/src/lib/core/plugin.js @@ -163,7 +163,6 @@ Plugin.prototype.addContractFile = function(file) { Plugin.prototype.registerConsoleCommand = function(optionsOrCb) { if (typeof optionsOrCb === 'function') { this.logger.warn(__('Registering console commands with function syntax is deprecated and will likely be removed in future versions of Embark.')); - // TODO add docs on how to register when they are written } this.console.push(optionsOrCb); this.addPluginType('console'); diff --git a/src/lib/modules/console/index.ts b/src/lib/modules/console/index.ts index f944eae015..241a784ee3 100644 --- a/src/lib/modules/console/index.ts +++ b/src/lib/modules/console/index.ts @@ -104,7 +104,7 @@ class Console { ]; helpDescriptions.forEach((helpDescription) => { let matches = [] as string[]; - if (typeof helpDescription.matches === "object") { + if (Array.isArray(helpDescription.matches)) { matches = helpDescription.matches as string[]; } helpText.push(`${(helpDescription.usage || matches.join("/")).cyan} - ${helpDescription.description}`); @@ -219,7 +219,10 @@ class Console { private registerConsoleCommands() { this.embark.registerConsoleCommand({ description: __("display console commands history"), - matches: ["history"], + matches: (cmd: string) => { + const [cmdName] = cmd.split(" "); + return cmdName === "history"; + }, process: (cmd: string, callback: any) => { const [_cmdName, length] = cmd.split(" "); this.getHistory(length, callback);