fix: via command error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-02-26 09:38:08 +00:00
parent 150c18957c
commit 6766c3b0ce
2 changed files with 2 additions and 3 deletions

View File

@ -2,14 +2,13 @@
function CommandHandlerDefault() {
this.on = function(jsp, name, exec) {
var cmd = this.create(jsp, { name: name });
console.debug('插件 %s 创建命令 %s(%s)...'.format(jsp.description.name, name, cmd))
if (exec.cmd && typeof exec.cmd === "function") {
console.debug('插件 %s 设置命令 %s 执行器(%s) ...'.format(jsp.description.name, name, cmd));
this.onCommand(jsp, cmd, exec.cmd)
} else {
throw Error("CommandExec Must be a function... Input: " + exec.cmd)
}
if (exec.tab && typeof exec.tab === "function") {
console.debug('插件 %s 设置命令 %s 自动补全(%s) ...'.format(jsp.description.name, name, cmd));
this.onTabComplete(jsp, cmd, exec.tab)
}
}

View File

@ -50,7 +50,7 @@ function disable(jsp) {
function create(jsp, command) {
var cmd = commandMap.getCommand(command.name)
if (cmd) { return cmd };
if (cmd && cmd instanceof PluginCommand) { return cmd };
cmd = ref.on(PluginCommand).create(command.name, plugin).get();
commandMap.register(jsp.description.name, cmd);
return cmd;