diff --git a/lib/cli/command-processor.js b/lib/cli/command-processor.js index 488b7904..7e39ae7d 100644 --- a/lib/cli/command-processor.js +++ b/lib/cli/command-processor.js @@ -141,14 +141,14 @@ module.exports = class CommandProcessor extends EventEmitter { } disconnect(callback) { - if (this.cli.client) { - return this.cli.client.disconnect(() => { - this.cli.connection = null; - this.cli.client = null; - callback(); - }); + if (!this.cli.client) { + return callback(new Error('Not connected')); } - callback(new Error('Not connected')); + this.cli.client.disconnect(() => { + this.cli.connection = null; + this.cli.client = null; + callback(); + }); } exit() {