Skip to content

Commit 09dd19a

Browse files
author
Ruben Bridgewater
committed
Add sanity check for unhandled commands with movable keys
1 parent 935a844 commit 09dd19a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
Features
44

5+
- Added build sanity check for unhandled commands with moveable keys
56
- Rebuild the commands with the newest unstable release
67

78
Bugfix

tools/build.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ var fs = require('fs');
22
var path = require('path');
33
var stringify = require('json-stable-stringify');
44
var commandPath = path.join(__dirname, '..', 'commands.json');
5+
var redisCommands = require('../');
56

67
var Redis = require('ioredis');
78
var redis = new Redis(process.env.REDIS_URI);
89

9-
redis.command(function (err, res) {
10+
return redis.command().then(function (res) {
1011
redis.disconnect();
1112

12-
if (err) {
13-
throw err;
14-
}
13+
// Find all special handled cases
14+
var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
15+
return entry.replace(/^case \'|\':$/g, '');
16+
});
1517

1618
var commands = res.reduce(function (prev, current) {
19+
if (current[2].indexOf('movablekeys') !== -1) {
20+
movableKeys.splice(movableKeys.indexOf(current[0]), 1);
21+
}
1722
// https://github.com/antirez/redis/issues/2598
1823
if (current[0] === 'brpop' && current[4] === 1) {
1924
current[4] = -2;
@@ -44,6 +49,10 @@ redis.command(function (err, res) {
4449
}
4550
}
4651

52+
if (movableKeys.length !== 0) {
53+
throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code');
54+
}
55+
4756
// Use json-stable-stringify instead fo JSON.stringify
4857
// for easier diffing
4958
var content = stringify(commands, { space: ' ' });

0 commit comments

Comments
 (0)