1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

feat(parser): update to latest Redis parser & errors (#1470)

* Update redis errors and redis parser
* Fix lint errors
* Add node 12 to travis ci
* Add appveyor node 12
* Fix some of existing errors

This drops support for hiredis.
This commit is contained in:
Vissarut Tantiwattanarom
2020-02-03 21:53:56 +04:00
committed by GitHub
parent 1f082aca54
commit 78936ac50c
9 changed files with 50 additions and 47 deletions

View File

@@ -14,6 +14,7 @@ node_js:
- "4"
- "6"
- "8"
- "12"
after_success: npm run coveralls
before_script:
# Add an IPv6 config - see the corresponding Travis issue

View File

@@ -8,6 +8,7 @@ environment:
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "12"
pull_requests:
do_not_increment_build_number: true

View File

@@ -9,6 +9,7 @@ var Queue = require('denque');
var errorClasses = require('./lib/customErrors');
var EventEmitter = require('events');
var Parser = require('redis-parser');
var RedisErrors = require('redis-errors');
var commands = require('redis-commands');
var debug = require('./lib/debug');
var unifyOptions = require('./lib/createClient');
@@ -1090,9 +1091,9 @@ exports.RedisClient = RedisClient;
exports.print = utils.print;
exports.Multi = require('./lib/multi');
exports.AbortError = errorClasses.AbortError;
exports.RedisError = Parser.RedisError;
exports.ParserError = Parser.ParserError;
exports.ReplyError = Parser.ReplyError;
exports.RedisError = RedisErrors.RedisError;
exports.ParserError = RedisErrors.ParserError;
exports.ReplyError = RedisErrors.ReplyError;
exports.AggregateError = errorClasses.AggregateError;
// Add all redis commands / node_redis api to the client

View File

@@ -2,14 +2,13 @@
var util = require('util');
var assert = require('assert');
var RedisError = require('redis-parser').RedisError;
var RedisError = require('redis-errors').RedisError;
var ADD_STACKTRACE = false;
function AbortError (obj, stack) {
assert(obj, 'The options argument is required');
assert.strictEqual(typeof obj, 'object', 'The options argument has to be of type object');
RedisError.call(this, obj.message, ADD_STACKTRACE);
Object.defineProperty(this, 'message', {
value: obj.message || '',
configurable: true,

View File

@@ -27,7 +27,8 @@
"dependencies": {
"denque": "^1.2.3",
"redis-commands": "^1.4.0",
"redis-parser": "^2.6.0"
"redis-errors": "^1.2.0",
"redis-parser": "^3.0.0"
},
"engines": {
"node": ">=0.10.0"

View File

@@ -359,7 +359,7 @@ describe('The node_redis client', function () {
it('send_command with callback as args', function (done) {
client.send_command('abcdef', function (err, res) {
assert.strictEqual(err.message, "ERR unknown command 'abcdef'");
assert.strictEqual(err.message, 'ERR unknown command `abcdef`, with args beginning with: ');
done();
});
});

View File

@@ -50,7 +50,7 @@ describe('rename commands', function () {
});
client.get('key', function (err, reply) {
assert.strictEqual(err.message, "ERR unknown command 'get'");
assert.strictEqual(err.message, 'ERR unknown command `get`, with args beginning with: `key`, ');
assert.strictEqual(err.command, 'GET');
assert.strictEqual(reply, undefined);
});
@@ -108,7 +108,7 @@ describe('rename commands', function () {
multi.exec(function (err, res) {
assert(err);
assert.strictEqual(err.message, 'EXECABORT Transaction discarded because of previous errors.');
assert.strictEqual(err.errors[0].message, "ERR unknown command 'get'");
assert.strictEqual(err.errors[0].message, 'ERR unknown command `get`, with args beginning with: `key`, ');
assert.strictEqual(err.errors[0].command, 'GET');
assert.strictEqual(err.code, 'EXECABORT');
assert.strictEqual(err.errors[0].code, 'ERR');