Skip to content

Commit

Permalink
Merge pull request #6725 from elastic/jasper/backport/6706/6724/4.5
Browse files Browse the repository at this point in the history
[backport] PR #6706 to 4.5
  • Loading branch information
epixa committed Apr 1, 2016
2 parents 1353fb0 + 60de9e4 commit bbbb5a6
Show file tree
Hide file tree
Showing 78 changed files with 270 additions and 267 deletions.
2 changes: 1 addition & 1 deletion src/cli/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Command.prototype.parseOptions = _.wrap(Command.prototype.parseOptions, function

Command.prototype.action = _.wrap(Command.prototype.action, function (action, fn) {
return action.call(this, function (...args) {
var ret = fn.apply(this, args);
let ret = fn.apply(this, args);
if (ret && typeof ret.then === 'function') {
ret.then(null, function (e) {
console.log('FATAL CLI ERROR', e.stack);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ program
.command('help <command>')
.description('Get the help for a specific command')
.action(function (cmdName) {
var cmd = _.find(program.commands, { _name: cmdName });
let cmd = _.find(program.commands, { _name: cmdName });
if (!cmd) return this.error(`unknown command ${cmdName}`);
cmd.help();
});
Expand All @@ -34,7 +34,7 @@ program
});

// check for no command name
var subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
let subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);

if (!subCommand) {
if (_.intersection(argv.slice(2), ['-h', '--help']).length) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cluster/ClusterManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = class ClusterManager {
}

setupWatching() {
var chokidar = require('chokidar');
let chokidar = require('chokidar');
let utils = require('requirefrom')('src/utils');
let fromRoot = utils('fromRoot');

Expand Down
4 changes: 2 additions & 2 deletions src/cli/color.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

var _ = require('lodash');
var ansicolors = require('ansicolors');
let _ = require('lodash');
let ansicolors = require('ansicolors');

exports.green = _.flow(ansicolors.black, ansicolors.bgGreen);
exports.red = _.flow(ansicolors.white, ansicolors.bgRed);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var _ = require('lodash');
let _ = require('lodash');

module.exports = function (command, spaces) {
if (!_.size(command.commands)) {
Expand Down Expand Up @@ -69,6 +69,6 @@ ${indent(cmd.optionHelp(), 2)}
}

function humanReadableArgName(arg) {
var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
let nameOutput = arg.name + (arg.variadic === true ? '...' : '');
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}
2 changes: 1 addition & 1 deletion src/cli/plugin/__tests__/plugin_installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('kibana cli', function () {
pluginPath: testWorkingPath
};

var errorStub = sinon.stub();
let errorStub = sinon.stub();
return pluginInstaller.install(settings, logger)
.catch(errorStub)
.then(function (data) {
Expand Down
82 changes: 41 additions & 41 deletions src/cli/plugin/__tests__/setting_parser.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var path = require('path');
var expect = require('expect.js');
let path = require('path');
let expect = require('expect.js');

var utils = require('requirefrom')('src/utils');
var fromRoot = utils('fromRoot');
var settingParser = require('../setting_parser');
let utils = require('requirefrom')('src/utils');
let fromRoot = utils('fromRoot');
let settingParser = require('../setting_parser');

describe('kibana cli', function () {

Expand All @@ -13,56 +13,56 @@ describe('kibana cli', function () {

describe('parseMilliseconds function', function () {

var parser = settingParser();
let parser = settingParser();

it('should return 0 for an empty string', function () {
var value = '';
let value = '';

var result = parser.parseMilliseconds(value);
let result = parser.parseMilliseconds(value);

expect(result).to.be(0);
});

it('should return 0 for a number with an invalid unit of measure', function () {
var result = parser.parseMilliseconds('1gigablasts');
let result = parser.parseMilliseconds('1gigablasts');
expect(result).to.be(0);
});

it('should assume a number with no unit of measure is specified as milliseconds', function () {
var result = parser.parseMilliseconds(1);
let result = parser.parseMilliseconds(1);
expect(result).to.be(1);

result = parser.parseMilliseconds('1');
expect(result).to.be(1);
});

it('should interpret a number with "s" as the unit of measure as seconds', function () {
var result = parser.parseMilliseconds('5s');
let result = parser.parseMilliseconds('5s');
expect(result).to.be(5 * 1000);
});

it('should interpret a number with "second" as the unit of measure as seconds', function () {
var result = parser.parseMilliseconds('5second');
let result = parser.parseMilliseconds('5second');
expect(result).to.be(5 * 1000);
});

it('should interpret a number with "seconds" as the unit of measure as seconds', function () {
var result = parser.parseMilliseconds('5seconds');
let result = parser.parseMilliseconds('5seconds');
expect(result).to.be(5 * 1000);
});

it('should interpret a number with "m" as the unit of measure as minutes', function () {
var result = parser.parseMilliseconds('9m');
let result = parser.parseMilliseconds('9m');
expect(result).to.be(9 * 1000 * 60);
});

it('should interpret a number with "minute" as the unit of measure as minutes', function () {
var result = parser.parseMilliseconds('9minute');
let result = parser.parseMilliseconds('9minute');
expect(result).to.be(9 * 1000 * 60);
});

it('should interpret a number with "minutes" as the unit of measure as minutes', function () {
var result = parser.parseMilliseconds('9minutes');
let result = parser.parseMilliseconds('9minutes');
expect(result).to.be(9 * 1000 * 60);
});

Expand Down Expand Up @@ -120,15 +120,15 @@ describe('kibana cli', function () {

it('should default to false', function () {
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings.quiet).to.be(false);
});

it('should set settings.quiet property to true', function () {
options.parent = { quiet: true };
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings.quiet).to.be(true);
});
Expand All @@ -139,15 +139,15 @@ describe('kibana cli', function () {

it('should default to false', function () {
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('silent', false);
});

it('should set settings.silent property to true', function () {
options.silent = true;
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('silent', true);
});
Expand All @@ -159,15 +159,15 @@ describe('kibana cli', function () {

it('should default to 0 (milliseconds)', function () {
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('timeout', 0);
});

it('should set settings.timeout property to specified value', function () {
options.timeout = 1234;
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('timeout', 1234);
});
Expand All @@ -179,7 +179,7 @@ describe('kibana cli', function () {
it('should set settings.action property to "install"', function () {
options.install = 'org/package/version';
parser = settingParser(options);
var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('action', 'install');
});
Expand All @@ -190,7 +190,7 @@ describe('kibana cli', function () {

expect(parser.parse).withArgs().to.not.throwError();

var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('organization', 'kibana');
expect(settings).to.have.property('package', 'test-plugin');
Expand All @@ -203,7 +203,7 @@ describe('kibana cli', function () {

expect(parser.parse).withArgs().to.not.throwError();

var settings = parser.parse(options);
let settings = parser.parse(options);

expect(settings).to.have.property('organization', 'kibana');
expect(settings).to.have.property('package', 'test-plugin');
Expand All @@ -228,7 +228,7 @@ describe('kibana cli', function () {
options.install = 'kibana/test-plugin';
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings.urls).to.have.property('length', 1);
expect(settings.urls).to.contain('https://download.elastic.co/kibana/test-plugin/test-plugin-latest.tar.gz');
Expand All @@ -238,7 +238,7 @@ describe('kibana cli', function () {
options.install = 'kibana/test-plugin/v1.1.1';
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings.urls).to.have.property('length', 1);
expect(settings.urls).to.contain('https://download.elastic.co/kibana/test-plugin/test-plugin-v1.1.1.tar.gz');
Expand All @@ -248,8 +248,8 @@ describe('kibana cli', function () {
options.install = 'kibana/test-plugin';
parser = settingParser(options);

var settings = parser.parse();
var expected = fromRoot('installedPlugins/test-plugin');
let settings = parser.parse();
let expected = fromRoot('installedPlugins/test-plugin');

expect(settings).to.have.property('pluginPath', expected);
});
Expand All @@ -258,8 +258,8 @@ describe('kibana cli', function () {
options.install = 'kibana/test-plugin';
parser = settingParser(options);

var settings = parser.parse();
var expected = fromRoot('installedPlugins/.plugin.installing');
let settings = parser.parse();
let expected = fromRoot('installedPlugins/.plugin.installing');

expect(settings).to.have.property('workingPath', expected);
});
Expand All @@ -268,8 +268,8 @@ describe('kibana cli', function () {
options.install = 'kibana/test-plugin';
parser = settingParser(options);

var settings = parser.parse();
var expected = fromRoot('installedPlugins/.plugin.installing/archive.part');
let settings = parser.parse();
let expected = fromRoot('installedPlugins/.plugin.installing/archive.part');

expect(settings).to.have.property('tempArchiveFile', expected);
});
Expand All @@ -283,7 +283,7 @@ describe('kibana cli', function () {

expect(parser.parse).withArgs().to.not.throwError();

var settings = parser.parse();
let settings = parser.parse();

expect(settings).to.have.property('package', 'test-plugin');
});
Expand All @@ -298,12 +298,12 @@ describe('kibana cli', function () {
});

it('should result in only the specified url in urls collection', function () {
var url = 'http://www.google.com/plugin.tar.gz';
let url = 'http://www.google.com/plugin.tar.gz';
options.install = 'test-plugin';
options.url = url;
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings).to.have.property('urls');
expect(settings.urls).to.be.an('array');
Expand All @@ -322,7 +322,7 @@ describe('kibana cli', function () {
options.remove = 'package';
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings).to.have.property('action', 'remove');
});
Expand All @@ -332,7 +332,7 @@ describe('kibana cli', function () {
options.remove = 'test-plugin';
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings).to.have.property('package', 'test-plugin');
});
Expand All @@ -351,8 +351,8 @@ describe('kibana cli', function () {
options.remove = 'test-plugin';
parser = settingParser(options);

var settings = parser.parse();
var expected = fromRoot('installedPlugins/test-plugin');
let settings = parser.parse();
let expected = fromRoot('installedPlugins/test-plugin');

expect(settings).to.have.property('pluginPath', expected);
});
Expand All @@ -367,7 +367,7 @@ describe('kibana cli', function () {
options.list = true;
parser = settingParser(options);

var settings = parser.parse();
let settings = parser.parse();

expect(settings).to.have.property('action', 'list');
});
Expand Down
14 changes: 7 additions & 7 deletions src/fixtures/agg_resp/geohash_grid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
return function GeoHashGridAggResponseFixture() {

var _ = require('lodash');
let _ = require('lodash');

// for vis:
//
Expand All @@ -18,23 +18,23 @@ define(function (require) {
// },
// });

var geoHashCharts = _.union(
let geoHashCharts = _.union(
_.range(48, 57), // 0-9
_.range(65, 90), // A-Z
_.range(97, 122) // a-z
);

var totalDocCount = 0;
let totalDocCount = 0;

var tags = _.times(_.random(4, 20), function (i) {
let tags = _.times(_.random(4, 20), function (i) {
// random number of tags
var docCount = 0;
var buckets = _.times(_.random(40, 200), function () {
let docCount = 0;
let buckets = _.times(_.random(40, 200), function () {
return _.sample(geoHashCharts, 3).join('');
})
.sort()
.map(function (geoHash) {
var count = _.random(1, 5000);
let count = _.random(1, 5000);

totalDocCount += count;
docCount += count;
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fake_chart_events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var results = {};
let results = {};

results.timeSeries = {
data: {
Expand Down
2 changes: 1 addition & 1 deletion src/fixtures/fake_hierarchical_data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var data = { };
let data = { };

data.metricOnly = {
hits: { total: 1000, hits: [], max_score: 0 },
Expand Down
Loading

0 comments on commit bbbb5a6

Please sign in to comment.