Files
elasticsearch-js/grunt/tasks.js
Dominykas Blyžė f1de944809 Upgrade to lodash v4 (#660)
* npm install lodash-2

Someone handily published a lodash-2 v4.17.4 - it is exactly the same as lodash v4.17.4, so it is safe to use during the migration.

* use lodash-2 in tests

* update tests to split utils vs lodash

* remove Utils.nextTick usage

Utils.nextTick with a single argument is the same as process.nextTick

* lowercase utils

Because it seems that this is the coding style in this repo

* upgrade lodash in grunt/*

* keep lodash-2 as a dev dep for now

* use lodash-2 in scripts

* use snakeCase from utils

It was a mistake in my previous commit to not update this usage

* fix naming gruntUtils vs utils

As all three - gruntUtils, utils and lodash (_) are getting passed into templates, it makes sense to keep the naming consistent

* fix naming gruntUtils vs utils

As all three - gruntUtils, utils and lodash (_) are getting passed into templates, it makes sense to keep the naming consistent

* split utils vs lodash in scripts/generate

Also use lodash-2 where it is easy to do so

* use utils.get until lodash upgrade

* remove lodash.isempty; lodash-2 now used in prod (in src/lib/apis/ code)

* unbundle lodash from utils

* upgrade to lodash 4

* remove lodash.get and lodash.trimEnd

* clean out unused code

* clean out unused code

* fix a breaking change listed under "notable changes" rather than under "breaking changes"...
2018-05-14 11:37:23 -07:00

81 lines
2.3 KiB
JavaScript

module.exports = function (grunt) {
var Promise = require('bluebird');
var gruntUtils = require('./utils');
var readFile = Promise.promisify(require('fs').readFile);
var writeFile = Promise.promisify(require('fs').writeFile);
// Default task runs the build process.
grunt.registerTask('default', [
'test'
]);
grunt.registerTask('test', function (branch) {
var tasks = [
branch ? 'run:generate_' + branch : 'run:generate',
'mochacov:unit'
];
var branches = branch ? [branch] : gruntUtils.branches;
process.env.ES_PORT = process.env.ES_PORT || 9400;
process.env.ES_HOST = process.env.ES_HOST || 'localhost';
branches.forEach(function (branch) {
tasks.push(
'esvm:' + branch,
'mocha_integration:' + branch,
'esvm_shutdown:' + branch
);
});
grunt.task.run(tasks);
});
grunt.registerTask('unit_test', 'mochacov:unit');
grunt.registerTask('coverage', [
'mochacov:make_coverage_html',
'open:coverage'
]);
grunt.registerTask('version', function (nextVersion) {
var root = require('path').join.bind(null, __dirname, '..');
var readmePath = root('README.md');
var packagePath = root('package.json');
var browserBuildsPath = root('docs/browser_builds.asciidoc');
Promise.all([
require(packagePath),
readFile(readmePath, 'utf8'),
readFile(browserBuildsPath, 'utf8')
])
.spread(function (pkg, readme, browserBuilds) {
var current = pkg.version;
pkg.version = nextVersion;
browserBuilds = gruntUtils.replaceAll(browserBuilds, current, nextVersion);
readme = gruntUtils.replaceAll(readme, current, nextVersion);
readme = gruntUtils.replaceAll(
readme,
'/' + gruntUtils.minorVersion(current) + '.svg',
'/' + gruntUtils.minorVersion(nextVersion) + '.svg'
);
readme = gruntUtils.replaceAll(
readme,
'branch=' + gruntUtils.minorVersion(current),
'branch=' + gruntUtils.minorVersion(nextVersion)
);
// write all files to disk
return Promise.all([
writeFile(readmePath, readme),
writeFile(browserBuildsPath, browserBuilds),
writeFile(packagePath, JSON.stringify(pkg, null, ' '))
]);
})
.nodeify(this.async());
});
};