@@ -2,18 +2,24 @@ 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
+ 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
+ var currentCommandPos = movableKeys . indexOf ( current [ 0 ] ) ;
20
+ if ( currentCommandPos !== - 1 && current [ 2 ] . indexOf ( 'movablekeys' ) !== - 1 ) {
21
+ movableKeys . splice ( currentCommandPos , 1 ) ;
22
+ }
17
23
// https://github.com/antirez/redis/issues/2598
18
24
if ( current [ 0 ] === 'brpop' && current [ 4 ] === 1 ) {
19
25
current [ 4 ] = - 2 ;
@@ -44,6 +50,10 @@ redis.command(function (err, res) {
44
50
}
45
51
}
46
52
53
+ if ( movableKeys . length !== 0 ) {
54
+ throw new Error ( 'Not all commands (\'' + movableKeys . join ( '\', \'' ) + '\') with the "movablekeys" flag are handled in the code' ) ;
55
+ }
56
+
47
57
// Use json-stable-stringify instead fo JSON.stringify
48
58
// for easier diffing
49
59
var content = stringify ( commands , { space : ' ' } ) ;
0 commit comments