You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Replace jshint with eslint and add lots of rules
Fix eslint errors accordingly
This commit is contained in:
@@ -13,8 +13,8 @@ var config = {
|
||||
redis: redis,
|
||||
PORT: 6379,
|
||||
HOST: {
|
||||
IPv4: "127.0.0.1",
|
||||
IPv6: "::1"
|
||||
IPv4: '127.0.0.1',
|
||||
IPv6: '::1'
|
||||
},
|
||||
configureClient: function (parser, ip, opts) {
|
||||
var args = [];
|
||||
|
@@ -52,11 +52,11 @@ module.exports = {
|
||||
var spawnFailed = false;
|
||||
// spawn redis with our testing configuration.
|
||||
var confFile = conf || path.resolve(__dirname, '../conf/redis.conf');
|
||||
var rp = spawn("redis-server", [confFile], {});
|
||||
var rp = spawn('redis-server', [confFile], {});
|
||||
|
||||
// capture a failure booting redis, and give
|
||||
// the user running the test some directions.
|
||||
rp.once("exit", function (code) {
|
||||
rp.once('exit', function (code) {
|
||||
if (code !== 0) spawnFailed = true;
|
||||
});
|
||||
|
||||
@@ -71,7 +71,7 @@ module.exports = {
|
||||
},
|
||||
stop: function (done) {
|
||||
if (spawnFailed) return done();
|
||||
rp.once("exit", function (code) {
|
||||
rp.once('exit', function (code) {
|
||||
var error = null;
|
||||
if (code !== null && code !== 0) {
|
||||
error = new Error('Redis shutdown failed with code ' + code);
|
||||
@@ -80,7 +80,7 @@ module.exports = {
|
||||
return done(error);
|
||||
}, port);
|
||||
});
|
||||
rp.kill("SIGTERM");
|
||||
rp.kill('SIGTERM');
|
||||
}
|
||||
});
|
||||
}, port);
|
||||
|
@@ -12,16 +12,16 @@ if (typeof EventEmitter !== 'function') {
|
||||
EventEmitter = EventEmitter.EventEmitter;
|
||||
}
|
||||
|
||||
function once(cb) {
|
||||
function once (cb) {
|
||||
var called = false;
|
||||
return function() {
|
||||
return function () {
|
||||
if (called) return;
|
||||
called = true;
|
||||
cb.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function StunnelProcess(conf_dir) {
|
||||
function StunnelProcess (conf_dir) {
|
||||
EventEmitter.call(this);
|
||||
|
||||
// set up an stunnel to redis; edit the conf file to include required absolute paths
|
||||
@@ -33,16 +33,16 @@ function StunnelProcess(conf_dir) {
|
||||
|
||||
// handle child process events, and failure to set up tunnel
|
||||
var self = this;
|
||||
this.timer = setTimeout(function() {
|
||||
this.timer = setTimeout(function () {
|
||||
self.emit('error', new Error('Timeout waiting for stunnel to start'));
|
||||
}, 8000);
|
||||
|
||||
stunnel.on('error', function(err) {
|
||||
stunnel.on('error', function (err) {
|
||||
self.clear();
|
||||
self.emit('error', err);
|
||||
});
|
||||
|
||||
stunnel.on('exit', function(code) {
|
||||
stunnel.on('exit', function (code) {
|
||||
self.clear();
|
||||
if (code === 0) {
|
||||
self.emit('stopped');
|
||||
@@ -52,7 +52,7 @@ function StunnelProcess(conf_dir) {
|
||||
});
|
||||
|
||||
// wait to stunnel to start
|
||||
stunnel.stderr.on("data", function(data) {
|
||||
stunnel.stderr.on('data', function (data) {
|
||||
if (data.toString().match(/Service.+redis.+bound/)) {
|
||||
clearTimeout(this.timer);
|
||||
self.emit('started');
|
||||
@@ -61,25 +61,25 @@ function StunnelProcess(conf_dir) {
|
||||
}
|
||||
util.inherits(StunnelProcess, EventEmitter);
|
||||
|
||||
StunnelProcess.prototype.clear = function() {
|
||||
StunnelProcess.prototype.clear = function () {
|
||||
this.stunnel = null;
|
||||
clearTimeout(this.timer);
|
||||
};
|
||||
|
||||
StunnelProcess.prototype.stop = function(done) {
|
||||
StunnelProcess.prototype.stop = function (done) {
|
||||
if (this.stunnel) {
|
||||
this.stunnel.kill();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
start: function(done, conf_dir) {
|
||||
start: function (done, conf_dir) {
|
||||
done = once(done);
|
||||
var stunnel = new StunnelProcess(conf_dir);
|
||||
stunnel.once('error', done.bind(done));
|
||||
stunnel.once('started', done.bind(done, null, stunnel));
|
||||
},
|
||||
stop: function(stunnel, done) {
|
||||
stop: function (stunnel, done) {
|
||||
stunnel.removeAllListeners();
|
||||
stunnel.stop();
|
||||
stunnel.once('error', done.bind(done));
|
||||
|
@@ -3,15 +3,15 @@
|
||||
// as soon as there are no outstanding commands.
|
||||
'use strict';
|
||||
|
||||
var redis = require("../../index");
|
||||
var redis = require('../../index');
|
||||
var HOST = process.argv[2] || '127.0.0.1';
|
||||
var PORT = process.argv[3];
|
||||
var args = PORT ? [PORT, HOST] : [HOST];
|
||||
|
||||
var c = redis.createClient.apply(redis, args);
|
||||
c.info(function (err, reply) {
|
||||
if (err) process.exit(-1);
|
||||
if (!reply.length) process.exit(-1);
|
||||
process.stdout.write(reply.length.toString());
|
||||
if (err) process.exit(-1);
|
||||
if (!reply.length) process.exit(-1);
|
||||
process.stdout.write(reply.length.toString());
|
||||
});
|
||||
c.unref();
|
||||
|
Reference in New Issue
Block a user