Merge pull request #408 from spalger/upgrade/lodash

Fix eslint errors and upgrade lodash
This commit is contained in:
Spencer
2016-05-19 15:20:11 -07:00
68 changed files with 518 additions and 253 deletions

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
src/_*
src/bower_es_js
src/lib/apis

View File

@ -1,5 +1,3 @@
'use strict';
module.exports = function (grunt) {
// load plugins
require('load-grunt-config')(grunt, {

View File

@ -2,4 +2,4 @@ module.exports = {
dist: {
src: ['<%= distDir %>']
}
};
};

View File

@ -11,8 +11,8 @@ function archive(out) {
}
module.exports = {
master_zip: archive('elasticsearch-js-master.zip'),
master_tarball: archive('elasticsearch-js-master.tar.gz'),
release_zip: archive('elasticsearch-js-<%= package.version %>.zip'),
release_tarball: archive('elasticsearch-js-<%= package.version %>.tar.gz')
};
master_zip: archive('elasticsearch-js-master.zip'),
master_tarball: archive('elasticsearch-js-master.tar.gz'),
release_zip: archive('elasticsearch-js-<%= package.version %>.zip'),
release_tarball: archive('elasticsearch-js-<%= package.version %>.tar.gz')
};

View File

@ -15,4 +15,4 @@ module.exports = {
footer: '\n}());'
}
}
};
};

View File

@ -11,4 +11,4 @@ module.exports = {
dest: '<%= bowerSubmodule %>',
expand: true
}
};
};

View File

@ -78,4 +78,4 @@ grunt.registerTask('mocha_jenkins_integration', function (branch) {
grunt.task.run('mochacov:jenkins_integration');
});
module.exports = config;
module.exports = config;

View File

@ -3,4 +3,4 @@ module.exports = {
path: 'coverage.html',
app: 'Google Chrome'
}
};
};

View File

@ -9,4 +9,4 @@ module.exports = {
}]
}
}
};
};

View File

@ -22,4 +22,4 @@ module.exports = {
}
}
}
};
};

View File

@ -33,4 +33,4 @@ module.exports = {
]
}
}
};
};

View File

@ -31,19 +31,19 @@ utils.minorVersion = function (version) {
utils.increaseVersion = function (version, type) {
var i;
switch (type) {
case 'major':
i = 0;
break;
case 'minor':
i = 1;
break;
case 'bug':
case 'patch':
case 'bugfix':
i = 2;
break;
default:
throw new TypeError('unexpected version bump type');
case 'major':
i = 0;
break;
case 'minor':
i = 1;
break;
case 'bug':
case 'patch':
case 'bugfix':
i = 2;
break;
default:
throw new TypeError('unexpected version bump type');
}
// breakout the current version

View File

@ -96,7 +96,7 @@
"dependencies": {
"chalk": "^1.0.0",
"forever-agent": "^0.6.0",
"lodash": "^3.10.0",
"lodash": "^4.12.0",
"lodash-compat": "^3.0.0",
"promise": "^7.1.1"
},
@ -107,7 +107,8 @@
"scripts": {
"test": "grunt test",
"generate": "node scripts/generate",
"grunt": "grunt"
"grunt": "grunt",
"eslint": "eslint src scripts test grunt Gruntfile.js"
},
"engines": {
"node": ">=0.8"

View File

@ -1,6 +1,6 @@
var _ = require('lodash');
var package = require('../package.json');
var branches = package.config.supported_es_branches;
var pkg = require('../package.json');
var branches = pkg.config.supported_es_branches;
var semver = require('semver');
var maxMinorVersion = function (majorV) {
@ -48,7 +48,7 @@ Version.prototype.mergeOpts = function (opts) {
return self.satisfies(rule.version);
})
.map(_.ary(_.partialRight(_.omit, 'version'), 1))
.concat(_.rest(arguments))
.concat(_.tail(arguments))
.reverse()
.reduce(_.merge, {});
};

View File

@ -60,4 +60,4 @@ function _spawn(cmd, args, opts, cb) {
_spawn.exec = function (cmd, opts, cb) {
return _spawn('/bin/sh', ['-c', cmd], opts, cb);
};
};

View File

@ -23,7 +23,7 @@ var through2 = require('through2');
var map = require('through2-map');
var split = require('split');
var join = require('path').join;
var child_process = require('child_process');
var cp = require('child_process');
var chalk = require('chalk');
var format = require('util').format;
@ -59,10 +59,10 @@ task('SAUCE_LABS', false, function () {
return new Promise(function (resolve, reject) {
// build the clients and start the server, once the server is ready call trySaucelabs()
var serverTasks = ['browser_clients:build', 'run:browser_test_server:keepalive'];
spawn(GRUNT, serverTasks, function (cp) {
spawn(GRUNT, serverTasks, function (proc) {
var toLines = split();
cp.stdout
proc.stdout
.pipe(toLines)
.pipe(through2(function (line, enc, cb) {
cb();
@ -71,11 +71,11 @@ task('SAUCE_LABS', false, function () {
trySaucelabs()
.finally(function () { cp && cp.kill(); })
.finally(function () { if (proc) proc.kill(); })
.then(resolve, reject);
cp.on('exit', function () { cp = null; });
cp.stdout.unpipe(toLines);
proc.on('exit', function () { proc = null; });
proc.stdout.unpipe(toLines);
toLines.end();
}));
})
@ -132,25 +132,30 @@ task('CHECK_COVERAGE', false, function () {
execTask('SETUP', function () {
return Promise.try(function readVersion() {
if (!ENV.ES_V) {
if (ENV.ES_RELEASE)
if (ENV.ES_RELEASE) {
return ['v' + ENV.ES_RELEASE, ENV.ES_RELEASE];
}
if (ENV.ES_REF)
if (ENV.ES_REF) {
return [ENV.ES_REF, null];
}
}
var match;
if (match = ENV.ES_V.match(/^(.*)_nightly$/))
if (match = ENV.ES_V.match(/^(.*)_nightly$/)) {
return [match[1], null];
}
if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V))
if (/^(?:1\.\d+|0\.90)\..*$/.test(ENV.ES_V)) {
return ['v' + ENV.ES_V, ENV.ES_V];
}
throw new Error('unable to parse ES_V ' + ENV.ES_V);
})
.then(function readOtherConf(ver) {
if (!ver)
if (!ver) {
throw new Error('Unable to run the ci script without at least an ES_REF or ES_RELEASE environment var.');
}
log('ES_PORT:', ENV.ES_PORT = parseInt(ENV.ES_PORT || 9400, 10));
log('ES_HOST:', ENV.ES_HOST = ENV.ES_HOST || 'localhost');
@ -162,8 +167,9 @@ execTask('SETUP', function () {
else delete ENV.ES_RELEASE;
})
.then(function readTasks() {
if (!ENV.RUN)
return _.where(TASKS, { default: true });
if (!ENV.RUN) {
return _.filter(TASKS, { default: true });
}
return ENV.RUN
.split(',')
@ -196,7 +202,7 @@ execTask('SETUP', function () {
});
});
/******
/** ****
* utils
******/
function log() {
@ -275,25 +281,25 @@ function execTask(name, task) {
function spawn(file, args, block) {
return new Promise(function (resolve, reject) {
var cp = child_process.spawn(file, args, {
var proc = cp.spawn(file, args, {
cwd: ROOT,
env: ENV,
stdio: [0, 'pipe', 'pipe']
});
cp.stdout.pipe(taskOut, { end: false });
cp.stderr.pipe(taskOut, { end: false });
proc.stdout.pipe(taskOut, { end: false });
proc.stderr.pipe(taskOut, { end: false });
var stdout = '';
cp.stdout
proc.stdout
.pipe(through2(function (chunk, enc, cb) {
stdout += chunk;
cb();
}));
block && block(cp);
if (block) block(proc);
cp.on('exit', function (code) {
proc.on('exit', function (code) {
if (code > 0) {
reject(new Error('non-zero exit code: ' + code));
} else {
@ -301,13 +307,13 @@ function spawn(file, args, block) {
}
});
cp.on('error', function (origErr) {
proc.on('error', function (origErr) {
reject(new Error('Unable to execute "' + file + ' ' + args.join(' ') + '": ' + origErr.message));
});
});
}
function node(/*args... */) {
function node(/* args... */) {
return spawn(
process.execPath,
_.toArray(arguments)

View File

@ -1,4 +1,4 @@
/*jshint curly: false */
/* jshint curly: false */
var async = require('async');
var fs = require('fs');
var spawn = require('../_spawn');
@ -95,7 +95,7 @@ function dirRegex(dir, regexp) {
function dirOpts(dir, opts) {
opts = _.isArray(opts) ? opts : [opts];
return dirFilter(dir, function (name) {
return _.contains(opts, name);
return _.includes(opts, name);
});
}
@ -206,7 +206,7 @@ function createArchive(branch) {
spawnStep('mkdir', [dir], paths.root),
spawnStep('git', ['archive', '--format', 'tar', '--output', tarball, branch, specPathInRepo], paths.esSrc),
spawnStep('tar', ['-x', '-f', tarball, '-C', dir, '--strip-components', subDirCount]),
spawnStep('rm', [tarball])
spawnStep('rm', [tarball])
], done);
};
}

View File

@ -87,7 +87,7 @@ module.exports = function (branch, done) {
apiSpec = {
actions: groups.normal || [],
proxies: groups.proxies || [],
namespaces: _.unique(namespaces.sort(), true),
namespaces: _.uniq(namespaces.sort()),
clientActionModifier: overrides.clientActionModifier
};
@ -170,12 +170,12 @@ module.exports = function (branch, done) {
);
}
function __puke__transformSpec(spec) {
function __puke__transformSpec(spec) { // eslint-disable-line
var actions = [];
// itterate all of the specs within the file, should only be one
_.each(spec, function (def, name) {
//camelcase the name
// camelcase the name
name = _.map(name.split('.'), _.camelCase).join('.');
if (name === 'cat.aliases') {
@ -239,7 +239,7 @@ module.exports = function (branch, done) {
urlSignatures.push(_.union(_.keys(optionalVars), _.keys(requiredVars)).sort().join(':'));
return _.omit({
return _.omitBy({
fmt: url.replace(urlParamRE, function (full, match) {
return '<%=' + _.camelCase(match) + '%>';
}),
@ -251,8 +251,14 @@ module.exports = function (branch, done) {
});
});
if (urlSignatures.length !== _.unique(urlSignatures).length) {
throw new Error('Multiple URLS with the same signature detected for ' + spec.name + '\n' + _.pluck(urls, 'fmt').join('\n') + '\n');
if (urlSignatures.length !== _.uniq(urlSignatures).length) {
throw new Error(
'Multiple URLS with the same signature detected for ' +
spec.name +
'\n' +
_.map(urls, 'fmt').join('\n') +
'\n'
);
}
if (urls.length > 1) {

View File

@ -187,6 +187,7 @@ module.exports = [
version: '>=1.6.0',
// strange indentation makes pretty api files
/* eslint-disable */
clientActionModifier:
function (spec) {
return require('../utils').merge(spec, {
@ -198,13 +199,15 @@ function (spec) {
}
});
}
/* eslint-enable */
},
{
version: '>=2.0.0',
aliases: {
'reindex.rethrottle': [
'/_update_by_query/{task_id}/_rethrottle'
'/_update_by_query/{task_id}/_rethrottle',
'/_delete_by_query/{task_id}/_rethrottle'
]
}
}

View File

@ -11,19 +11,19 @@ api._namespaces = <%= stringify(namespaces) %>;<%
_.each(actions, function (action) {
var namespace = action.location.split('.').shift();
if (_.contains(namespaces, namespace)) {
if (_.includes(namespaces, namespace)) {
_.pull(namespaces, namespace);
%>
api.<%= namespace %> = namespace();<%
}%>
<%= partials.client_action(action) %><%
<%= _.trimEnd(partials.client_action(action)) %><%
});
_.each(proxies, function (action) {%>
<%= partials.client_action_proxy(action) %><%
<%= _.trimEnd(partials.client_action_proxy(action)) %><%
});
%>

View File

@ -9,4 +9,4 @@ _.each(allParams, function(param, paramName) { %>
}
%><% }) %>
*/
api<%= (location[0] === '[' ? '' : '.') + location %> = ca(<%= stringify(spec, true) %>);
api<%= (location[0] === '[' ? '' : '.') + location %> = ca(<%= stringify(spec, true) %>);

View File

@ -16,4 +16,4 @@ if (typeof transformBody === 'string') { %>, {
}
}<%
}
%>);
%>);

View File

@ -14,7 +14,7 @@ var path = require('path');
*/
function stringify(thing, pretty) {
return (pretty ? JSON.stringify(thing, null, ' ') : JSON.stringify(thing))
.replace(/\'/g, '\\\'')
.replace(/'/g, '\\\'')
.replace(/\\?"/g, function (quote) {
// replace external (unescaped) double quotes with single quotes
return quote === '\\"' ? '"' : '\'';
@ -68,16 +68,16 @@ var templateGlobals = {
paramType: function (type) {
switch (type && type.toLowerCase ? type.toLowerCase() : 'any') {
case 'time':
return 'Date, Number';
case 'any':
return 'Anything';
case 'enum':
return 'String';
case 'list':
return 'String, String[], Boolean';
default:
return _.ucfirst(type);
case 'time':
return 'Date, Number';
case 'any':
return 'Anything';
case 'enum':
return 'String';
case 'list':
return 'String, String[], Boolean';
default:
return _.ucfirst(type);
}
},

View File

@ -51,8 +51,8 @@ module.exports = function (branch, done) {
function writeTestIndex(done) {
var file = fromRoot('test/integration/yaml_suite/index_' + _.snakeCase(branch) + '.js');
fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');', 'utf8');
fs.writeFileSync(file, 'require(\'./run\')(\'' + branch + '\');\n', 'utf8');
console.log(chalk.white.bold('wrote') + ' YAML index to', file);
done();
}
};
};

View File

@ -42,4 +42,4 @@ async.series([
console.log('Error: ', err.message ? err.message : err);
}
}
});
});

View File

@ -19,4 +19,4 @@
return new es.Client(config);
};
}(jQuery));
}(jQuery));

View File

@ -1661,6 +1661,257 @@ api['delete'] = ca({
method: 'DELETE'
});
/**
* Perform a [deleteByQuery](https://www.elastic.co/guide/en/elasticsearch/plugins/master/plugins-reindex.html) request
*
* @param {Object} params - An object with parameters used to carry out this action
* @param {String} params.analyzer - The analyzer to use for the query string
* @param {Boolean} params.analyzeWildcard - Specify whether wildcard and prefix queries should be analyzed (default: false)
* @param {String} [params.defaultOperator=OR] - The default operator for query string query (AND or OR)
* @param {String} params.df - The field to use as default where no field prefix is given in the query string
* @param {Boolean} params.explain - Specify whether to return detailed information about score computation as part of a hit
* @param {String, String[], Boolean} params.fields - A comma-separated list of fields to return as part of a hit
* @param {String, String[], Boolean} params.fielddataFields - A comma-separated list of fields to return as the field data representation of a field for each hit
* @param {Number} params.from - Starting offset (default: 0)
* @param {Boolean} params.ignoreUnavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {Boolean} params.allowNoIndices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {String} [params.conflicts=abort] - What to do when the delete-by-query hits version conflicts?
* @param {String} [params.expandWildcards=open] - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {Boolean} params.lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
* @param {Boolean} params.lowercaseExpandedTerms - Specify whether query terms should be lowercased
* @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random)
* @param {String} params.q - Query in the Lucene query string syntax
* @param {String, String[], Boolean} params.routing - A comma-separated list of specific routing values
* @param {Duration} params.scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {String} params.searchType - Search operation type
* @param {Date, Number} params.searchTimeout - Explicit timeout for each search request. Defaults to no timeout.
* @param {Number} params.size - Number of hits to return (default: 10)
* @param {String, String[], Boolean} params.sort - A comma-separated list of <field>:<direction> pairs
* @param {String, String[], Boolean} params._source - True or false to return the _source field or not, or a list of fields to return
* @param {String, String[], Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field
* @param {String, String[], Boolean} params._sourceInclude - A list of fields to extract and return from the _source field
* @param {Number} params.terminateAfter - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
* @param {String, String[], Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes
* @param {String} params.suggestField - Specify which field to use for suggestions
* @param {String} [params.suggestMode=missing] - Specify suggest mode
* @param {Number} params.suggestSize - How many suggestions to return in response
* @param {Text} params.suggestText - The source text for which the suggestions should be returned
* @param {Date, Number} [params.timeout=1m] - Time each individual bulk request should wait for shards that are unavailable.
* @param {Boolean} params.trackScores - Whether to calculate and return scores even if they are not used for sorting
* @param {Boolean} params.version - Specify whether to return document version as part of a hit
* @param {Boolean} params.requestCache - Specify if request cache should be used for this request or not, defaults to index level setting
* @param {Boolean} params.refresh - Should the effected indexes be refreshed?
* @param {String} params.consistency - Explicit write consistency setting for the operation
* @param {Integer} params.scrollSize - Size on the scroll request powering the update_by_query
* @param {Boolean} params.waitForCompletion - Should the request should block until the delete-by-query is complete.
* @param {Float} params.requestsPerSecond - The throttle for this request in sub-requests per second. 0 means set no throttle.
* @param {String, String[], Boolean} params.index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {String, String[], Boolean} params.type - A comma-separated list of document types to search; leave empty to perform the operation on all types
*/
api.deleteByQuery = ca({
params: {
analyzer: {
type: 'string'
},
analyzeWildcard: {
type: 'boolean',
name: 'analyze_wildcard'
},
defaultOperator: {
type: 'enum',
'default': 'OR',
options: [
'AND',
'OR'
],
name: 'default_operator'
},
df: {
type: 'string'
},
explain: {
type: 'boolean'
},
fields: {
type: 'list'
},
fielddataFields: {
type: 'list',
name: 'fielddata_fields'
},
from: {
type: 'number'
},
ignoreUnavailable: {
type: 'boolean',
name: 'ignore_unavailable'
},
allowNoIndices: {
type: 'boolean',
name: 'allow_no_indices'
},
conflicts: {
type: 'enum',
'default': 'abort',
options: [
'abort',
'proceed'
]
},
expandWildcards: {
type: 'enum',
'default': 'open',
options: [
'open',
'closed',
'none',
'all'
],
name: 'expand_wildcards'
},
lenient: {
type: 'boolean'
},
lowercaseExpandedTerms: {
type: 'boolean',
name: 'lowercase_expanded_terms'
},
preference: {
type: 'string'
},
q: {
type: 'string'
},
routing: {
type: 'list'
},
scroll: {
type: 'duration'
},
searchType: {
type: 'enum',
options: [
'query_then_fetch',
'dfs_query_then_fetch'
],
name: 'search_type'
},
searchTimeout: {
type: 'time',
name: 'search_timeout'
},
size: {
type: 'number'
},
sort: {
type: 'list'
},
_source: {
type: 'list'
},
_sourceExclude: {
type: 'list',
name: '_source_exclude'
},
_sourceInclude: {
type: 'list',
name: '_source_include'
},
terminateAfter: {
type: 'number',
name: 'terminate_after'
},
stats: {
type: 'list'
},
suggestField: {
type: 'string',
name: 'suggest_field'
},
suggestMode: {
type: 'enum',
'default': 'missing',
options: [
'missing',
'popular',
'always'
],
name: 'suggest_mode'
},
suggestSize: {
type: 'number',
name: 'suggest_size'
},
suggestText: {
type: 'text',
name: 'suggest_text'
},
timeout: {
type: 'time',
'default': '1m'
},
trackScores: {
type: 'boolean',
name: 'track_scores'
},
version: {
type: 'boolean'
},
requestCache: {
type: 'boolean',
name: 'request_cache'
},
refresh: {
type: 'boolean'
},
consistency: {
type: 'enum',
options: [
'one',
'quorum',
'all'
]
},
scrollSize: {
type: 'integer',
name: 'scroll_size'
},
waitForCompletion: {
type: 'boolean',
'default': false,
name: 'wait_for_completion'
},
requestsPerSecond: {
type: 'float',
'default': 0,
name: 'requests_per_second'
}
},
urls: [
{
fmt: '/<%=index%>/<%=type%>/_delete_by_query',
req: {
index: {
type: 'list'
},
type: {
type: 'list'
}
}
},
{
fmt: '/<%=index%>/_delete_by_query',
req: {
index: {
type: 'list'
}
}
}
],
needBody: true,
method: 'POST'
});
/**
* Perform a [deleteScript](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request
*

View File

@ -56,11 +56,11 @@ function Client(config) {
this.transport = new Transport(config);
_.each(EsApiClient.prototype, function (Fn, prop) {
_.each(EsApiClient.prototype, _.bind(function (Fn, prop) {
if (Fn.prototype instanceof clientAction.ApiNamespace) {
this[prop] = new Fn(this.transport);
}
}, this);
}, this));
delete this._namespaces;
}

View File

@ -106,9 +106,9 @@ function Host(config, globalConfig) {
delete config.auth;
}
_.forOwn(config, function (val, prop) {
_.forOwn(config, _.bind(function (val, prop) {
if (val != null) this[prop] = _.clone(val);
}, this);
}, this));
// make sure the query string is parsed
if (this.query === null) {

View File

@ -64,7 +64,7 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
this.listeningLevels = [];
_.each(levels, function (level) {
_.each(levels, _.bind(function (level) {
var fnName = 'on' + _.ucfirst(level);
if (this.bound[fnName]) {
this.listeningLevels.push(level);
@ -72,7 +72,7 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
} else {
throw new Error('Unable to listen for level "' + level + '"');
}
}, this);
}, this));
};
/**
@ -83,9 +83,9 @@ LoggerAbstract.prototype.setupListeners = function (levels) {
* @return {undefined}
*/
LoggerAbstract.prototype.cleanUpListeners = _.handler(function () {
_.each(this.listeningLevels, function (level) {
_.each(this.listeningLevels, _.bind(function (level) {
this.log.removeListener(level, this.bound['on' + _.ucfirst(level)]);
}, this);
}, this));
});
/**

View File

@ -274,7 +274,7 @@ Transport.prototype.request = function (params, cb) {
if (
(!err || err instanceof errors.Serialization)
&& (status < 200 || status >= 300)
&& (!params.ignore || !_.contains(params.ignore, status))
&& (!params.ignore || !_.includes(params.ignore, status))
) {
var errorMetadata = _.pick(params.req, ['path', 'query', 'body']);

View File

@ -1,5 +1,4 @@
var path = require('path');
var _ = require('lodash');
var nodeUtils = require('util');
/**
@ -10,16 +9,15 @@ var nodeUtils = require('util');
* @class utils
* @static
*/
var utils = _.extend({}, _, nodeUtils);
_ = utils;
var _ = require('lodash').assign({}, require('lodash'), nodeUtils);
/**
* Link to [path.join](http://nodejs.org/api/path.html#path_path_join_path1_path2)
*
* @method utils.joinPath
* @method _.joinPath
* @type {function}
*/
utils.joinPath = path.join;
_.joinPath = path.join;
/**
* Recursively merge two objects, walking into each object and concating arrays. If both to and from have a value at a
@ -31,7 +29,7 @@ utils.joinPath = path.join;
* @param {Object} from - Object to pull changed from
* @return {Object} - returns the modified to value
*/
utils.deepMerge = function (to, from) {
_.deepMerge = function (to, from) {
_.each(from, function (fromVal, key) {
switch (typeof to[key]) {
case 'undefined':
@ -42,7 +40,7 @@ utils.deepMerge = function (to, from) {
to[key] = to[key].concat(from[key]);
}
else if (_.isPlainObject(to[key]) && _.isPlainObject(from[key])) {
utils.deepMerge(to[key], from[key]);
_.deepMerge(to[key], from[key]);
}
}
});
@ -67,7 +65,7 @@ _.each([
], function (type) {
var check = _['is' + type];
utils['isArrayOf' + type + 's'] = function (arr) {
_['isArrayOf' + type + 's'] = function (arr) {
// quick shallow check of arrays
return _.isArray(arr) && _.every(arr.slice(0, 10), check);
};
@ -81,7 +79,7 @@ _.each([
* @param {string} word - The word to transform
* @return {string}
*/
utils.ucfirst = function (word) {
_.ucfirst = function (word) {
return word[0].toUpperCase() + word.substring(1).toLowerCase();
};
@ -142,7 +140,7 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) {
* @param {String} string
* @return {String}
*/
utils.studlyCase = adjustWordCase(true, true, '');
_.studlyCase = adjustWordCase(true, true, '');
/**
* Transform a string into camelCase
@ -151,7 +149,7 @@ utils.studlyCase = adjustWordCase(true, true, '');
* @param {String} string
* @return {String}
*/
utils.camelCase = adjustWordCase(false, true, '');
_.camelCase = adjustWordCase(false, true, '');
/**
* Transform a string into snakeCase
@ -160,7 +158,7 @@ utils.camelCase = adjustWordCase(false, true, '');
* @param {String} string
* @return {String}
*/
utils.snakeCase = adjustWordCase(false, false, '_');
_.snakeCase = adjustWordCase(false, false, '_');
/**
* Lower-case a string, and return an empty string if any is not a string
@ -168,7 +166,7 @@ utils.snakeCase = adjustWordCase(false, false, '_');
* @param any {*} - Something or nothing
* @returns {string}
*/
utils.toLowerString = function (any) {
_.toLowerString = function (any) {
if (any) {
if (typeof any !== 'string') {
any = any.toString();
@ -185,7 +183,7 @@ utils.toLowerString = function (any) {
* @param any {*} - Something or nothing
* @returns {string}
*/
utils.toUpperString = function (any) {
_.toUpperString = function (any) {
if (any) {
if (typeof any !== 'string') {
any = any.toString();
@ -203,7 +201,7 @@ utils.toUpperString = function (any) {
* @param {*} val
* @return {Boolean}
*/
utils.isNumeric = function (val) {
_.isNumeric = function (val) {
return typeof val !== 'object' && val - parseFloat(val) >= 0;
};
@ -217,7 +215,7 @@ var intervalRE = /^(\d+(?:\.\d+)?)(M|w|d|h|m|s|y|ms)$/;
* @param {String} val
* @return {Boolean}
*/
utils.isInterval = function (val) {
_.isInterval = function (val) {
return !!(val.match && val.match(intervalRE));
};
@ -230,7 +228,7 @@ utils.isInterval = function (val) {
* @param {Number} times - Times the string should be repeated
* @return {String}
*/
utils.repeat = function (what, times) {
_.repeat = function (what, times) {
return (new Array(times + 1)).join(what);
};
@ -243,7 +241,7 @@ utils.repeat = function (what, times) {
* @param [sliceIndex=0] {Integer} - The index that args should be sliced at, before feeding args to func
* @returns {*} - the return value of func
*/
utils.applyArgs = function (func, context, args, sliceIndex) {
_.applyArgs = function (func, context, args, sliceIndex) {
sliceIndex = sliceIndex || 0;
switch (args.length - sliceIndex) {
case 0:
@ -442,4 +440,4 @@ _.now = function () {
return (typeof Date.now === 'function') ? Date.now() : (new Date()).getTime();
};
module.exports = utils;
module.exports = _;

View File

@ -31,11 +31,11 @@ process.once('message', function (port) {
var out = {
socketCount: err || sockets.length,
remaining: _.where(sockets, { destroyed: true }).length - sockets.length,
timeouts: _.size(clock.timers) && _.pluck(clock.timers, 'func').map(String)
remaining: _.filter(sockets, { destroyed: true }).length - sockets.length,
timeouts: _.size(clock.timers) && _.map(clock.timers, 'func').map(String)
};
clock.restore();
process.connected ? process.send(out) : console.log(out);
});
});
});

View File

@ -13,4 +13,4 @@ var server = require('http').createServer(app);
server.listen(function () {
var port = server.address().port;
process.connected ? process.send(port) : console.log(port);
});
});

View File

@ -55,7 +55,8 @@ module.exports = {
function doCreateClient(options, cb) {
if (typeof options === 'function') {
cb = options, options = {};
cb = options;
options = {};
}
var logConfig = {};
@ -112,7 +113,7 @@ module.exports = {
snapshot: '_all'
})
.then(function (resp) {
return _.pluck(resp.snapshots, 'snapshot');
return _.map(resp.snapshots, 'snapshot');
}, function () {
return [];
})
@ -121,13 +122,13 @@ module.exports = {
repository: repo,
snapshot: snapshot
});
}, {concurrency: 1})
}, { concurrency: 1 })
.then(function () {
return client.snapshot.deleteRepository({
repository: repo
});
});
}, {concurrency: 1})
}, { concurrency: 1 })
]);
};

View File

@ -37,4 +37,4 @@ module.exports = function (branch) {
});
});
};
};

View File

@ -9,7 +9,7 @@
*/
module.exports = YamlDoc;
var _ = require('../../../src/lib/utils');
var _ = require('lodash');
var expect = require('expect.js');
var clientManager = require('./client_manager');
var inspect = require('util').inspect;
@ -26,10 +26,10 @@ var ES_VERSION = null;
var versionExp = '((?:\\d+\\.){0,2}\\d+)(?:[\\.\\-]\\w+)?|';
// match all whitespace within a "regexp" match arg
var reWhitespace_RE = /\s+/g;
var reWhitespaceRE = /\s+/g;
// match all comments within a "regexp" match arg
var reComments_RE = /([\S\s]?)#[^\n]*\n/g;
var reCommentsRE = /([\S\s]?)#[^\n]*\n/g;
/**
* Regular Expression to extract a version number from a string
@ -200,7 +200,7 @@ YamlDoc.prototype = {
// creates [ [ {name:"", args:"" }, ... ], ... ]
// from [ {name:args, name:args}, {name:args} ]
var actionSets = _.map(config, function (set) {
return _.map(_.pairs(set), function (pair) {
return _.map(_.toPairs(set), function (pair) {
return { name: pair[0], args: pair[1] };
});
});
@ -356,34 +356,34 @@ YamlDoc.prototype = {
// resolve the catch arg to a value used for matching once the request is complete
switch (args.catch) {
case void 0:
catcher = null;
break;
case 'missing':
catcher = 404;
break;
case 'conflict':
catcher = 409;
break;
case 'forbidden':
catcher = 403;
break;
case 'request_timeout':
catcher = 408;
break;
case 'request':
catcher = /.*/;
break;
case 'param':
catcher = TypeError;
break;
default:
catcher = args.catch.match(/^\/(.*)\/$/);
if (catcher) {
catcher = new RegExp(catcher[1]);
} else {
return done(new TypeError('unsupported catch type ' + args.catch));
}
case void 0:
catcher = null;
break;
case 'missing':
catcher = 404;
break;
case 'conflict':
catcher = 409;
break;
case 'forbidden':
catcher = 403;
break;
case 'request_timeout':
catcher = 408;
break;
case 'request':
catcher = /.*/;
break;
case 'param':
catcher = TypeError;
break;
default:
catcher = args.catch.match(/^\/(.*)\/$/);
if (catcher) {
catcher = new RegExp(catcher[1]);
} else {
return done(new TypeError('unsupported catch type ' + args.catch));
}
}
delete args.catch;
@ -407,7 +407,7 @@ YamlDoc.prototype = {
var clientAction = this.get(clientActionName, client);
_.assign(inputParams, args[action]);
var params = _.transform(inputParams, function (params, val, name) {
var params = _.transform(inputParams, _.bind(function (params, val, name) {
var camelName = _.camelCase(name);
// search through the params and url peices to find this param name
@ -437,18 +437,18 @@ YamlDoc.prototype = {
}.bind(this);
transformObject(params, val, paramName);
}, {}, this);
}, this), {});
expect(clientAction || clientActionName).to.be.a('function');
if (_.isNumeric(catcher)) {
if (!isNaN(parseFloat(catcher))) {
params.ignore = _.union(params.ignore || [], [catcher]);
catcher = null;
}
var timeoutId;
var cb = _.bind(function (error, body) {
var cb = _.bind(function (error, body) {
this._last_requests_response = body;
clearTimeout(timeoutId);
@ -494,9 +494,9 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_set: function (args) {
_.forOwn(args, function (name, path) {
_.forOwn(args, _.bind(function (name, path) {
this._stash[name] = this.get(path);
}, this);
}, this));
},
/**
@ -578,7 +578,7 @@ YamlDoc.prototype = {
}
});
_.forOwn(args, function (match, path) {
_.forOwn(args, _.bind(function (match, path) {
var origMatch = match;
var maybeRE = false;
@ -588,7 +588,7 @@ YamlDoc.prototype = {
// convert the matcher into a compatible string for building a regexp
maybeRE = match
// replace comments, but allow the # to be escaped like \#
.replace(reComments_RE, function (match, prevChar) {
.replace(reCommentsRE, function (match, prevChar) {
if (prevChar === '\\') {
return match;
} else {
@ -597,7 +597,7 @@ YamlDoc.prototype = {
})
// remove all whitespace from the expression, all meaningful
// whitespace is represented with \s
.replace(reWhitespace_RE, '');
.replace(reWhitespaceRE, '');
var startsWithSlash = maybeRE[0] === '/';
var endsWithSlash = maybeRE[maybeRE.length - 1] === '/';
@ -645,7 +645,7 @@ YamlDoc.prototype = {
throw new Error(msg.join('\n'));
}
}, this);
}, this));
},
/**
@ -655,9 +655,9 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_lt: function (args) {
_.forOwn(args, function (num, path) {
_.forOwn(args, _.bind(function (num, path) {
expect(this.get(path)).to.be.below(num, 'path: ' + path);
}, this);
}, this));
},
/**
@ -667,9 +667,9 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_lte: function (args) {
_.forOwn(args, function (num, path) {
_.forOwn(args, _.bind(function (num, path) {
expect(this.get(path) <= num).to.be.ok('path: ' + path);
}, this);
}, this));
},
/**
@ -679,9 +679,9 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_gt: function (args) {
_.forOwn(args, function (num, path) {
_.forOwn(args, _.bind(function (num, path) {
expect(this.get(path)).to.be.above(num, 'path: ' + path);
}, this);
}, this));
},
/**
@ -691,9 +691,9 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_gte: function (args) {
_.forOwn(args, function (num, path) {
_.forOwn(args, _.bind(function (num, path) {
expect(this.get(path) >= num).to.be.ok('path: ' + path);
}, this);
}, this));
},
/**
@ -704,8 +704,8 @@ YamlDoc.prototype = {
* @return {undefined}
*/
do_length: function (args) {
_.forOwn(args, function (len, path) {
_.forOwn(args, _.bind(function (len, path) {
expect(_.size(this.get(path))).to.eql(len, 'path: ' + path);
}, this);
}, this));
}
};

View File

@ -19,7 +19,7 @@ function YamlFile(filename, docs) {
describe(filename, function () {
file.docs = _.map(docs, function (doc) {
doc = new YamlDoc(doc, file);
doc = new YamlDoc(doc, file);
if (doc.description === 'setup') {
beforeEach(/* doc */function (done) {
async.series(doc.getActionsRunners(), done);

View File

@ -1,4 +1,4 @@
/* eslint-disable */
//////////////
/// Extended version of:
/// https://github.com/philikon/MockHttpRequest/

View File

@ -57,15 +57,15 @@ var mockNock = module.exports = function (url) {
req.status = status;
req.body = body;
switch (typeof req.body) {
case 'string':
case 'number':
break;
default:
try {
req.body = req.body && JSON.stringify(req.body);
} catch (e) {
req.body = req.body;
}
case 'string':
case 'number':
break;
default:
try {
req.body = req.body && JSON.stringify(req.body);
} catch (e) {
req.body = req.body;
}
}
interceptors.push(req);
return mockNock(url);
@ -80,4 +80,4 @@ mockNock.done = function () {
if (interceptors.length) {
throw new Error('Some interceptors were not called: ' + JSON.stringify(interceptors));
}
};
};

View File

@ -32,4 +32,4 @@ util.inherits(MockIncommingMessage, Readable);
* }
* incom.push(null);
* });
*/
*/

View File

@ -75,4 +75,4 @@ if (Writable) {
// There is no shutdown() for files.
MockWritableStream.prototype.destroySoon = MockWritableStream.prototype.end;
}
}

View File

@ -1,3 +1,4 @@
/* global angular */
var _ = require('lodash');
var expect = require('expect.js');
var Promise = require('bluebird');
@ -82,4 +83,4 @@ describe('Angular esFactory', function () {
return prom;
});
});
});
});

View File

@ -17,4 +17,4 @@ describe('elasticsearch namespace', function () {
expect(client.transport).to.be.a(es.Transport);
client.close();
});
});
});

View File

@ -1,3 +1,4 @@
/* global $ */
var expect = require('expect.js');
var Transport = require('../../../src/lib/transport');
@ -16,4 +17,4 @@ describe('jQuery.es namespace', function () {
expect(client.transport).to.be.a($.es.Transport);
client.close();
});
});
});

View File

@ -57,4 +57,4 @@ module.exports = function (makeLogger) {
});
}
});
};
};

View File

@ -1,5 +1,5 @@
var blanket = require("blanket")({
var blanket = require('blanket')({
pattern: require('path').join(__dirname, '../../src')
});
require('./index');
require('./index');

View File

@ -234,4 +234,4 @@ module.exports = function (makeLogger) {
expect(logger.write.callCount).to.eql(1);
});
});
};
};

View File

@ -3,4 +3,4 @@ require('bluebird').longStackTraces();
var specDir = __dirname + '/specs';
require('fs').readdirSync(specDir).forEach(function (file) {
require(specDir + '/' + file);
});
});

View File

@ -32,4 +32,4 @@ describe('Logger Abstract', function () {
require('../generic_logger_tests')(makeLogger);
});
});

View File

@ -68,7 +68,7 @@ describe('Client instances creation', function () {
}
util.inherits(NullStream, stream.Writable);
NullStream.prototype._write = function(/* chunk, encoding, next */) {
NullStream.prototype._write = function (/* chunk, encoding, next */) {
done();
};

View File

@ -195,7 +195,7 @@ describe('Client Action runner', function () {
it('rejects array', function (done) {
action({
one: ['one'],
two: [ 1304 ]
two: [1304]
}, function (err, params) {
expect(err).to.be.a(TypeError);
done();
@ -629,7 +629,7 @@ describe('Client Action runner', function () {
method: 'POST'
});
action({method: 'get'}, function (err, params) {
action({ method: 'get' }, function (err, params) {
expect(params.method).to.be('GET');
done();
});

View File

@ -17,11 +17,11 @@ describe('Connection Abstract', function () {
it('requires a valid host', function () {
expect(function () {
new ConnectionAbstract();
var conn = new ConnectionAbstract();
}).to.throwError(TypeError);
expect(function () {
new ConnectionAbstract({});
var conn = new ConnectionAbstract({});
}).to.throwError(TypeError);
});
@ -81,7 +81,6 @@ describe('Connection Abstract', function () {
it('calls it\'s own request method', function () {
var conn = new ConnectionAbstract(host);
var football = {};
stub(conn, 'request');
conn.ping();
expect(conn.request.callCount).to.eql(1);

View File

@ -1,6 +1,5 @@
var ConnectionPool = require('../../../src/lib/connection_pool');
var Host = require('../../../src/lib/host');
var errors = require('../../../src/lib/errors');
var ConnectionAbstract = require('../../../src/lib/connection');
var _ = require('lodash');
var EventEmitter = require('events').EventEmitter;
@ -121,7 +120,7 @@ describe('Connection Pool', function () {
});
it('detects if the selector is not async', function (done) {
pool.selector = function (list) {
pool.selector = function () {
expect(arguments.length).to.be(1);
};
@ -149,11 +148,11 @@ describe('Connection Pool', function () {
});
it('should catch errors in sync selectors', function (done) {
pool.selector = function (list) {
pool.selector = function () {
return JSON.notAMethod();
};
pool.select(function (err, selection) {
pool.select(function (err) {
expect(err).be.an(Error);
done();
});
@ -297,7 +296,8 @@ describe('Connection Pool', function () {
var result = pool.getConnections();
expect(result.length).to.be(1000);
expect(_.reduce(result, function (sum, num) {
return sum += num;
sum += num
return sum;
}, 0)).to.eql(499500);
});
});

View File

@ -32,7 +32,7 @@ describe('Host class', function () {
});
it('accepts a string for query', function () {
var host = new Host({ query: 'beep=boop'});
var host = new Host({ query: 'beep=boop' });
expect(host.query).to.eql({
beep: 'boop'
@ -157,14 +157,14 @@ describe('Host class', function () {
var host = new Host();
host.path = 'prefix';
expect(host.makeUrl({ path: '/this and that'}))
expect(host.makeUrl({ path: '/this and that' }))
.to.be('http://localhost:9200/prefix/this and that');
});
it('does not try to prevent double forward-slashes', function () {
var host = new Host({ path: 'prefix/' });
expect(host.makeUrl({ path: '/this and that'}))
expect(host.makeUrl({ path: '/this and that' }))
.to.be('http://localhost:9200/prefix//this and that');
});
@ -175,7 +175,7 @@ describe('Host class', function () {
host = new Host({ host: 'john', port: 80 });
expect(host.makeUrl()).to.be('http://john/');
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass'});
host = new Host({ host: 'italy', path: '/pie', auth: 'user:pass' });
expect(host.makeUrl()).to.be('http://italy:9200/pie');
});

View File

@ -324,7 +324,7 @@ describe('Http Connector', function () {
zlib.gzip(body, function (err, compressedBody) {
server
.get('/users/1')
.reply(200, compressedBody, {'Content-Encoding': 'gzip'});
.reply(200, compressedBody, { 'Content-Encoding': 'gzip' });
con.request({
method: 'GET',
@ -350,7 +350,7 @@ describe('Http Connector', function () {
zlib.deflate(body, function (err, compressedBody) {
server
.get('/users/1')
.reply(200, compressedBody, {'Content-Encoding': 'deflate'});
.reply(200, compressedBody, { 'Content-Encoding': 'deflate' });
con.request({
method: 'GET',
@ -371,7 +371,7 @@ describe('Http Connector', function () {
var body = 'blah';
server
.get('/users/1')
.reply(200, body, {'Content-Encoding': 'gzip'});
.reply(200, body, { 'Content-Encoding': 'gzip' });
con.request({
method: 'GET',

View File

@ -97,4 +97,4 @@ describe('JSON serializer', function () {
}).to.throwError();
});
});
});
});

View File

@ -141,7 +141,7 @@ describe('Log class', function () {
log.emit = function (eventName) {
call = {
event : eventName,
event: eventName,
args: Array.prototype.slice.call(arguments, 1)
};
};
@ -221,7 +221,7 @@ describe('Log class', function () {
});
it('accepts an array of output config objects', function () {
var log = new Log({ log: [{ level: 'error' }, { level: 'trace'}] });
var log = new Log({ log: [{ level: 'error' }, { level: 'trace' }] });
expect(log.listenerCount('error')).to.eql(2);
expect(log.listenerCount('warning')).to.eql(1);
expect(log.listenerCount('info')).to.eql(1);

View File

@ -61,7 +61,6 @@ describe('Nodes to host callback', function () {
});
it('ignores hosts that don\'t have an http_host property', function () {
var hosts = callback({
node_id: {
@ -74,7 +73,7 @@ describe('Nodes to host callback', function () {
it('throws an error when the host property is not formatted properly', function () {
expect(function () {
var hosts = callback({
callback({
node_id: {
http_address: 'not actually an http host'
}

View File

@ -1,7 +1,6 @@
var Transport = require('../../../src/lib/transport');
var Host = require('../../../src/lib/host');
var errors = require('../../../src/lib/errors');
var Promise = require('bluebird');
var sinon = require('sinon');
var expect = require('expect.js');
@ -354,10 +353,10 @@ describe('Transport Class', function () {
});
it('logs an error if nodes to host throws one', function (done) {
trans.nodesToHostCallback = function (nodes) {
trans.nodesToHostCallback = function () {
throw new Error('I failed');
};
trans.log.error = function (err) {
trans.log.error = function () {
done();
};
trans.sniff();
@ -408,7 +407,7 @@ describe('Transport Class', function () {
});
});
it('passed back the full server response', function (done) {
trans.sniff(function (err, resp, status) {
trans.sniff(function (err, resp) {
expect(resp.ok).to.eql(true);
expect(resp.cluster_name).to.eql('clustername');
done();
@ -501,7 +500,7 @@ describe('Transport Class', function () {
});
var conn = getConnection(trans);
var body = [
{ _id: 'simple body'},
{ _id: 'simple body' },
{ name: 'ഢധയമബ' }
];
@ -526,7 +525,7 @@ describe('Transport Class', function () {
var trans = new Transport({
hosts: 'localhost'
});
var conn = getConnection(trans);
getConnection(trans);
var body = {
_id: 'circular body'
};
@ -560,7 +559,7 @@ describe('Transport Class', function () {
}
});
trans.request({}, function (err, body, status) {
trans.request({}, function (err) {
expect(err.message).to.eql('I am broken');
});
});
@ -574,7 +573,7 @@ describe('Transport Class', function () {
}
});
trans.request({}, function (err, body, status) {
trans.request({}, function (err) {
expect(err.message).to.eql('I am broken');
});
});
@ -638,7 +637,6 @@ describe('Transport Class', function () {
});
describe('return value', function () {
it('returns an object with an abort() method when a callback is sent', function () {
var tran = new Transport();
@ -681,7 +679,7 @@ describe('Transport Class', function () {
expect(process.domain).to.be(null);
var tran = new Transport();
shortCircuitRequest(tran);
tran.request({}, function(err, result, status) {
tran.request({}, function () {
expect(process.domain).to.be(null);
});
});
@ -689,12 +687,12 @@ describe('Transport Class', function () {
it('binds the callback to the correct domain', function () {
expect(process.domain).to.be(null);
var domain = require('domain').create();
domain.run(function() {
domain.run(function () {
var tran = new Transport();
shortCircuitRequest(tran);
expect(process.domain).not.to.be(null);
var startingDomain = process.domain
tran.request({}, function(err, result, status) {
tran.request({}, function () {
expect(process.domain).not.to.be(null);
expect(process.domain).to.be(startingDomain);
process.domain.exit();
@ -758,7 +756,6 @@ describe('Transport Class', function () {
var clock = sinon.useFakeTimers('setTimeout', 'clearTimeout');
stub.autoRelease(clock);
var tran = new Transport({});
var err;
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
@ -776,7 +773,6 @@ describe('Transport Class', function () {
var tran = new Transport({
requestTimeout: 5000
});
var err;
var prom = tran.request({});
// disregard promise, prevent bluebird's warnings
@ -799,7 +795,7 @@ describe('Transport Class', function () {
tran.request({
requestTimeout: falsy
}, function (_err) {});
}, function () {});
expect(_.size(clock.timers)).to.eql(0);
});

View File

@ -32,7 +32,7 @@ describe('Utils', function () {
}
},
function (thing, name) {
describe('#isArrayOf' + name, function (test) {
describe('#isArrayOf' + name, function () {
it('likes arrays of ' + name, function () {
expect(_['isArrayOf' + name + 's'](thing.is)).to.be(true);
});
@ -54,7 +54,6 @@ describe('Utils', function () {
expect(_.isNumeric(0)).to.be(true);
expect(_.isNumeric(32)).to.be(true);
expect(_.isNumeric('040')).to.be(true);
expect(_.isNumeric(0144)).to.be(true);
expect(_.isNumeric('0xFF')).to.be(true);
expect(_.isNumeric(0xFFF)).to.be(true);
});
@ -196,7 +195,7 @@ describe('Utils', function () {
});
it('sorta kinda works on objects', function () {
expect(_.toLowerString({a: 'thing'})).to.eql('[object object]');
expect(_.toLowerString({ a: 'thing' })).to.eql('[object object]');
});
});
@ -216,7 +215,7 @@ describe('Utils', function () {
});
it('sorta kinda works on objects', function () {
expect(_.toUpperString({a: 'thing'})).to.eql('[OBJECT OBJECT]');
expect(_.toUpperString({ a: 'thing' })).to.eql('[OBJECT OBJECT]');
});
});
@ -268,7 +267,7 @@ describe('Utils', function () {
foo: ['bax', 'boz']
}
};
_.deepMerge(obj, { bax: { foo: ['poo'] }});
_.deepMerge(obj, { bax: { foo: ['poo'] } });
expect(obj.bax.foo).to.have.length(3);
});
@ -282,7 +281,7 @@ describe('Utils', function () {
expect(out).to.not.be(inp);
});
it('accepts a primitive value and calls the the transform function', function (done) {
var out = _.createArray('str', function (val) {
_.createArray('str', function (val) {
expect(val).to.be('str');
done();
});

View File

@ -19,4 +19,4 @@ describe('Yaml Test Reader', function () {
expect(compare('0.90 - 1.2', '1.4')).to.be(false);
});
});
});
});

View File

@ -18,4 +18,4 @@ exports.make = function () {
};
return stubber;
};
};

View File

@ -9,4 +9,4 @@ module.exports = function expectSubObject(obj, subObj) {
expect(obj).property(prop, val);
}
});
};
};

View File

@ -22,7 +22,7 @@ var log = (function () {
}
locked(str);
};
})();
}());
var integration = _.find(process.argv, function (arg) { return arg.indexOf('test/integration') > -1; });
var unit = _.find(process.argv, function (arg) { return arg.indexOf('test/unit') > -1; });
@ -86,7 +86,7 @@ function JenkinsReporter(runner) {
stack.shift();
});
runner.on('fail', function (test, err) {
runner.on('fail', function (test) {
if ('hook' === test.type) {
runner.emit('test end', test);
}

View File

@ -41,7 +41,7 @@ function makeJUnitXml(runnerName, testDetails) {
timestamp: moment(suiteInfo.start).toJSON(),
hostname: 'localhost',
tests: (suiteInfo.results && suiteInfo.results.length) || 0,
failures: _.where(suiteInfo.results, {pass: false}).length,
failures: _.filter(suiteInfo.results, { pass: false }).length,
errors: 0,
time: suiteInfo.time / 1000
});
@ -89,7 +89,7 @@ function makeJUnitXml(runnerName, testDetails) {
giveOutput(suite, suiteInfo);
});
return suites.toString({ pretty: true});
return suites.toString({ pretty: true });
}
function giveOutput(el, info) {
@ -103,4 +103,4 @@ function giveOutput(el, info) {
if (err) {
el.ele('system-err', {}).cdata(chalk.stripColor(err));
}
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable import/no-unresolved */
var express = require('express');
var http = require('http');
var fs = require('fs');
@ -31,6 +32,8 @@ testFiles.build = fs.readdirSync(browserBuildsDir)
if (file.substr(-3) === '.js') {
return browserBuildsDir + '/' + file;
}
return null
})
.filter(Boolean);
@ -73,7 +76,7 @@ function bundleTests(name) {
// create a route that just rends a specific file (like a symlink or something)
function sendFile(file) {
return function (req, res, next) {
return function (req, res) {
res.sendfile(file);
};
}
@ -111,4 +114,4 @@ app
http.createServer(app).listen(8000, function () {
console.log('listening on port 8000');
});
});

View File

@ -3,4 +3,4 @@
module.exports = JSON.parse(new Buffer(
'eyJ1c2VyIjoiZWxhc3RpY3NlYXJjaC1qcyIsImtleSI6IjI0ZjQ5ZTA3LWQ4MmYtNDA2Ny04NTRlLWQ4MTVlYmQxNWU0NiJ9',
'base64'
).toString('utf8'));
).toString('utf8'));