You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
chore - remove standard and use individual config
Standard is not as up to date and still uses a old eslint version. Instead, use the airbnb default with a couple of modifications. All required changes are included.
This commit is contained in:
@@ -11,7 +11,7 @@ const config = {
|
||||
IPv4: '127.0.0.1',
|
||||
IPv6: '::1'
|
||||
},
|
||||
configureClient (ip, opts) {
|
||||
configureClient(ip, opts) {
|
||||
const args = []
|
||||
// Do not manipulate the opts => copy them each time
|
||||
opts = opts ? JSON.parse(JSON.stringify(opts)) : {}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
// Spawned by the goodStacks.spec.js tests
|
||||
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
const redis = require('../../index')
|
||||
|
||||
const client = redis.createClient()
|
||||
|
||||
// Both error cases would normally return bad stack traces
|
||||
|
@@ -9,7 +9,7 @@ const tcpPortUsed = require('tcp-port-used')
|
||||
|
||||
// wait for redis to be listening in
|
||||
// all three modes (ipv4, ipv6, socket).
|
||||
function waitForRedis (available, cb, port) {
|
||||
function waitForRedis(available, cb, port) {
|
||||
if (process.platform === 'win32') return cb()
|
||||
|
||||
const time = Date.now()
|
||||
@@ -49,7 +49,7 @@ function waitForRedis (available, cb, port) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
start (done, conf, port) {
|
||||
start(done, conf, port) {
|
||||
let spawnFailed = false
|
||||
// spawn redis with our testing configuration.
|
||||
const confFile = conf || path.resolve(__dirname, '../conf/redis.conf')
|
||||
@@ -67,10 +67,10 @@ module.exports = {
|
||||
// return an object that can be used in
|
||||
// an after() block to shutdown redis.
|
||||
return done(null, {
|
||||
spawnFailed () {
|
||||
spawnFailed() {
|
||||
return spawnFailed
|
||||
},
|
||||
stop (done) {
|
||||
stop(done) {
|
||||
if (spawnFailed) return done()
|
||||
rp.once('exit', (code) => {
|
||||
let error = null
|
||||
|
@@ -1,22 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
// Helper to start and stop the stunnel process.
|
||||
const spawn = require('child_process').spawn
|
||||
const { spawn } = require('child_process')
|
||||
const EventEmitter = require('events')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const util = require('util')
|
||||
|
||||
function once (cb) {
|
||||
function once(cb) {
|
||||
let called = false
|
||||
return function () {
|
||||
return function (...args) {
|
||||
if (called) return
|
||||
called = true
|
||||
cb.apply(this, arguments)
|
||||
cb.apply(this, args)
|
||||
}
|
||||
}
|
||||
|
||||
function StunnelProcess (confDir) {
|
||||
function StunnelProcess(confDir) {
|
||||
EventEmitter.call(this)
|
||||
|
||||
// Set up an stunnel to redis; edit the conf file to include required absolute paths
|
||||
@@ -24,7 +24,8 @@ function StunnelProcess (confDir) {
|
||||
const confText = fs.readFileSync(`${confFile}.template`).toString().replace(/__dirname/g, confDir)
|
||||
|
||||
fs.writeFileSync(confFile, confText)
|
||||
const stunnel = this.stunnel = spawn('stunnel', [confFile])
|
||||
this.stunnel = spawn('stunnel', [confFile])
|
||||
const { stunnel } = this
|
||||
|
||||
// Handle child process events, and failure to set up tunnel
|
||||
this.timer = setTimeout(() => {
|
||||
@@ -67,13 +68,13 @@ StunnelProcess.prototype.stop = function (done) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
start (done, confDir) {
|
||||
done = once(done)
|
||||
start(doneOrig, confDir) {
|
||||
const done = once(doneOrig)
|
||||
const stunnel = new StunnelProcess(confDir)
|
||||
stunnel.once('error', done.bind(done))
|
||||
stunnel.once('started', done.bind(done, null, stunnel))
|
||||
},
|
||||
stop (stunnel, done) {
|
||||
stop(stunnel, done) {
|
||||
stunnel.removeAllListeners()
|
||||
stunnel.stop()
|
||||
stunnel.once('error', done.bind(done))
|
||||
|
@@ -1,14 +1,16 @@
|
||||
// spawned by the unref tests in nodeRedis.spec.js.
|
||||
// when configured, unref causes the client to exit
|
||||
// as soon as there are no outstanding commands.
|
||||
|
||||
'use strict'
|
||||
|
||||
const redis = require('../../index')
|
||||
|
||||
const HOST = process.argv[2] || '127.0.0.1'
|
||||
const PORT = process.argv[3]
|
||||
const args = PORT ? [PORT, HOST] : [HOST]
|
||||
|
||||
const c = redis.createClient.apply(redis, args)
|
||||
const c = redis.createClient(...args)
|
||||
c.info((err, reply) => {
|
||||
if (err) process.exit(-1)
|
||||
if (!reply.length) process.exit(-1)
|
||||
|
Reference in New Issue
Block a user