diff --git a/lib/redis.js b/lib/redis.js index ddaca72..f86405a 100644 --- a/lib/redis.js +++ b/lib/redis.js @@ -73,16 +73,16 @@ class RedisClient { } attachEvent() { - this.rl = readline.createInterface(process.stdin, process.stdout); + const rl = readline.createInterface(process.stdin, process.stdout); this._redis_client.on('ready', () => { if (this.mode !== "UNIXSOCKET") { - this.rl.setPrompt(`${this._host}:${this._port}> `); + rl.setPrompt(`${this._host}:${this._port}> `); } else { - this.rl.setPrompt(`${this._host}> `); + rl.setPrompt(`${this._host}> `); } - this.rl.prompt(); + rl.prompt(); - this.rl.on('line', async (line) => { + rl.on('line', async (line) => { line = new InputBuffer(line).toString(); try { let command = line.trim(); @@ -100,13 +100,13 @@ class RedisClient { readline.clearScreenDown(process.stdout); } else { this.execute([CMD, ...commands]).finally(() => { - this.rl.prompt(); + rl.prompt(); }); } } } catch (err) { console.log(colors.red(`(error) ${err.message}`)); - this.rl.prompt(); + rl.prompt(); } }).on('close', () => { console.log('\nAbort!');