change to isArray and fix history with length

This commit is contained in:
Jonathan Rainville 2018-12-14 09:12:29 -05:00
parent 79fe28d62e
commit ae61792d5b
2 changed files with 5 additions and 3 deletions

View File

@ -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');

View File

@ -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);