Explorar o código

[misc] do not access potentially undefined opts

Jakob Ackermann %!s(int64=5) %!d(string=hai) anos
pai
achega
6452959482

+ 1 - 1
libraries/redis-wrapper/index.js

@@ -33,7 +33,7 @@ function createClient(opts) {
   }
 
   let client
-  if (opts.cluster) {
+  if (standardOpts.cluster) {
     delete standardOpts.cluster
     client = new Redis.Cluster(opts.cluster, standardOpts)
   } else {

+ 4 - 0
libraries/redis-wrapper/test/unit/src/test.js

@@ -78,6 +78,10 @@ describe('index', function () {
       })
     })
 
+    it('should work without opts', function () {
+      this.redis.createClient()
+    })
+
     it('should use the ioredis driver in single-instance mode if a non array is passed', function () {
       const client = this.redis.createClient(this.standardOpts)
       return assert.equal(client.constructor, this.ioredis)