@@ -2,18 +2,23 @@ var fs = require('fs');
2
2
var path = require ( 'path' ) ;
3
3
var stringify = require ( 'json-stable-stringify' ) ;
4
4
var commandPath = path . join ( __dirname , '..' , 'commands.json' ) ;
5
+ var redisCommands = require ( '../' ) ;
5
6
6
7
var Redis = require ( 'ioredis' ) ;
7
8
var redis = new Redis ( process . env . REDIS_URI ) ;
8
9
9
- redis . command ( function ( err , res ) {
10
+ return redis . command ( ) . then ( function ( res ) {
10
11
redis . disconnect ( ) ;
11
12
12
- if ( err ) {
13
- throw err ;
14
- }
13
+ // Find all special handled cases
14
+ var movableKeys = String ( redisCommands . getKeyIndexes ) . match ( / c a s e ' [ a - z - ] + ' : / g) . map ( function ( entry ) {
15
+ return entry . replace ( / ^ c a s e \' | \' : $ / g, '' ) ;
16
+ } ) ;
15
17
16
18
var commands = res . reduce ( function ( prev , current ) {
19
+ if ( current [ 2 ] . indexOf ( 'movablekeys' ) !== - 1 ) {
20
+ movableKeys . splice ( movableKeys . indexOf ( current [ 0 ] ) , 1 ) ;
21
+ }
17
22
// https://github.com/antirez/redis/issues/2598
18
23
if ( current [ 0 ] === 'brpop' && current [ 4 ] === 1 ) {
19
24
current [ 4 ] = - 2 ;
@@ -44,6 +49,10 @@ redis.command(function (err, res) {
44
49
}
45
50
}
46
51
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
+
47
56
// Use json-stable-stringify instead fo JSON.stringify
48
57
// for easier diffing
49
58
var content = stringify ( commands , { space : ' ' } ) ;
0 commit comments