@@ -2,18 +2,24 @@ var fs = require('fs');
22var path = require ( 'path' ) ;
33var stringify = require ( 'json-stable-stringify' ) ;
44var commandPath = path . join ( __dirname , '..' , 'commands.json' ) ;
5+ var redisCommands = require ( '../' ) ;
56
67var Redis = require ( 'ioredis' ) ;
78var redis = new Redis ( process . env . REDIS_URI ) ;
89
9- redis . command ( function ( err , res ) {
10+ 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 ( / c a s e ' [ a - z - ] + ' : / g) . map ( function ( entry ) {
15+ return entry . replace ( / ^ c a s e \' | \' : $ / g, '' ) ;
16+ } ) ;
1517
1618 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+ }
1723 // https://github.com/antirez/redis/issues/2598
1824 if ( current [ 0 ] === 'brpop' && current [ 4 ] === 1 ) {
1925 current [ 4 ] = - 2 ;
@@ -44,6 +50,10 @@ redis.command(function (err, res) {
4450 }
4551 }
4652
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+
4757 // Use json-stable-stringify instead fo JSON.stringify
4858 // for easier diffing
4959 var content = stringify ( commands , { space : ' ' } ) ;
0 commit comments