Use standard and prettier (#10)
* switch from custom eslint config to standard + prettier * fix new standard eslint violations * add editorconfig file * auto-fix all other violations * update lint yarn script * remove jshint comment
This commit is contained in:
@ -21,37 +21,52 @@ var client = null;
|
||||
module.exports = {
|
||||
create: function create(apiVersion, port, host, cb) {
|
||||
// create a client and ping the server for up to 15 seconds
|
||||
doCreateClient({
|
||||
logConfig: null
|
||||
}, function () {
|
||||
var attemptsRemaining = 60;
|
||||
var timeout = 500;
|
||||
doCreateClient(
|
||||
{
|
||||
logConfig: null,
|
||||
},
|
||||
function() {
|
||||
var attemptsRemaining = 60;
|
||||
var timeout = 500;
|
||||
|
||||
(function ping() {
|
||||
client.info({
|
||||
maxRetries: 0,
|
||||
requestTimeout: 100
|
||||
}, function (err, resp) {
|
||||
if (err && --attemptsRemaining) {
|
||||
setTimeout(ping, timeout);
|
||||
} else if (err) {
|
||||
cb(new Error('unable to establish contact with ES at ' + JSON.stringify({
|
||||
host: host,
|
||||
port: port,
|
||||
err: err
|
||||
})));
|
||||
} else if (resp.name !== 'elasticsearch_js_test_runner') {
|
||||
console.log(resp);
|
||||
cb(new Error('Almosted wiped out another es node. Shut-down all instances of ES and try again.'));
|
||||
} else {
|
||||
// create a new client
|
||||
doCreateClient(function () {
|
||||
cb(void 0, client);
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
||||
});
|
||||
(function ping() {
|
||||
client.info(
|
||||
{
|
||||
maxRetries: 0,
|
||||
requestTimeout: 100,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err && --attemptsRemaining) {
|
||||
setTimeout(ping, timeout);
|
||||
} else if (err) {
|
||||
cb(
|
||||
new Error(
|
||||
'unable to establish contact with ES at ' +
|
||||
JSON.stringify({
|
||||
host: host,
|
||||
port: port,
|
||||
err: err,
|
||||
})
|
||||
)
|
||||
);
|
||||
} else if (resp.name !== 'elasticsearch_js_test_runner') {
|
||||
console.log(resp);
|
||||
cb(
|
||||
new Error(
|
||||
'Almosted wiped out another es node. Shut-down all instances of ES and try again.'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// create a new client
|
||||
doCreateClient(function() {
|
||||
cb(void 0, client);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
})();
|
||||
}
|
||||
);
|
||||
|
||||
function doCreateClient(options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
@ -90,50 +105,61 @@ module.exports = {
|
||||
hosts: [
|
||||
{
|
||||
host: host,
|
||||
port: port
|
||||
}
|
||||
port: port,
|
||||
},
|
||||
],
|
||||
log: logConfig,
|
||||
defer: function () {
|
||||
defer: function() {
|
||||
return Bluebird.defer();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
client.clearEs = function () {
|
||||
client.clearEs = function() {
|
||||
return Bluebird.all([
|
||||
client.indices.delete({ index: '*', ignore: 404 }),
|
||||
client.indices.deleteTemplate({ name: '*', ignore: 404 }),
|
||||
client.snapshot.getRepository()
|
||||
.then(_.keys)
|
||||
.map(function (repo) {
|
||||
return client.snapshot.get({
|
||||
repository: repo,
|
||||
snapshot: '_all'
|
||||
})
|
||||
.then(function (resp) {
|
||||
return _.map(resp.snapshots, 'snapshot');
|
||||
}, function () {
|
||||
return [];
|
||||
})
|
||||
.map(function (snapshot) {
|
||||
return client.snapshot.delete({
|
||||
repository: repo,
|
||||
snapshot: snapshot
|
||||
});
|
||||
}, { concurrency: 1 })
|
||||
.then(function () {
|
||||
return client.snapshot.deleteRepository({
|
||||
repository: repo
|
||||
});
|
||||
});
|
||||
}, { concurrency: 1 })
|
||||
client.snapshot
|
||||
.getRepository()
|
||||
.then(_.keys)
|
||||
.map(
|
||||
function(repo) {
|
||||
return client.snapshot
|
||||
.get({
|
||||
repository: repo,
|
||||
snapshot: '_all',
|
||||
})
|
||||
.then(
|
||||
function(resp) {
|
||||
return _.map(resp.snapshots, 'snapshot');
|
||||
},
|
||||
function() {
|
||||
return [];
|
||||
}
|
||||
)
|
||||
.map(
|
||||
function(snapshot) {
|
||||
return client.snapshot.delete({
|
||||
repository: repo,
|
||||
snapshot: snapshot,
|
||||
});
|
||||
},
|
||||
{ concurrency: 1 }
|
||||
)
|
||||
.then(function() {
|
||||
return client.snapshot.deleteRepository({
|
||||
repository: repo,
|
||||
});
|
||||
});
|
||||
},
|
||||
{ concurrency: 1 }
|
||||
),
|
||||
]);
|
||||
};
|
||||
|
||||
process.nextTick(cb);
|
||||
}
|
||||
},
|
||||
get: function () {
|
||||
get: function() {
|
||||
return client;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user