clean up lodash 4 upgrade crumbs

This commit is contained in:
spalger
2017-02-13 15:18:05 -07:00
parent 6c70facc65
commit adb3de5b3b
12 changed files with 64 additions and 23 deletions

View File

@ -41,16 +41,14 @@ Version.prototype.satisfies = function (range) {
// merge a list of option objects, each of which has a "version" key dictating
// the range of versions those options should be included in. Options are merged
// in the order of the array
Version.prototype.mergeOpts = function (opts) {
var self = this;
Version.prototype.mergeOpts = function (versioned, overrides) {
return opts.filter(function (rule) {
return self.satisfies(rule.version);
})
.map(_.ary(_.partialRight(_.omit, 'version'), 1))
.concat(_.tail(arguments))
.reverse()
.reduce(_.merge, {});
const candidates = versioned
.filter(o => this.satisfies(o.version))
.map(o => _.omit(o, 'version'))
.reverse()
return _.merge({}, overrides || {}, ...candidates)
};
module.exports = Version;

View File

@ -98,7 +98,7 @@ function dirRegex(dir, regexp) {
function dirOpts(dir, opts) {
opts = _.isArray(opts) ? opts : [opts];
return dirFilter(dir, function (name) {
return _.includes(opts, name);
return _.include(opts, name);
});
}
@ -174,7 +174,7 @@ function clearGeneratedFiles() {
generatedFiles.push(dirRegex(paths.src, esArchives));
var rmSteps = _.chain(generatedFiles)
.flattenDeep()
.flatten()
.uniq()
.map(function (path) {
return spawnStep('rm', ['-rf', path]);
@ -202,7 +202,7 @@ function createArchive(branch) {
var dir = paths.getArchiveDir(branch);
var tarball = paths.getArchiveTarball(branch);
var specPathInRepo = paths.getSpecPathInRepo(branch);
var subDirCount = _.countBy(specPathInRepo, _.partial(_.eq, '/')).true || 0;
var subDirCount = _.countBy(specPathInRepo, p => p === '/').true || 0;
if (isDirectory(dir)) {
console.log(branch + ' archive already exists');

View File

@ -207,7 +207,7 @@ module.exports = function (branch, done) {
_.forOwn(allParams, (paramSpec, paramName) => {
const toMerge = _.get(overrides, ['mergeConcatParams', name, paramName])
if (toMerge) {
_.mergeWith(paramSpec, toMerge, (dest, src) => {
_.merge(paramSpec, toMerge, (dest, src) => {
if (_.isArray(dest) && _.isArray(src)) {
return dest.concat(src)
}
@ -263,7 +263,7 @@ module.exports = function (branch, done) {
urlSignatures.push(_.union(_.keys(optionalVars), _.keys(requiredVars)).sort().join(':'));
return _.omitBy({
return _.omit({
fmt: url.replace(urlParamRE, function (full, match) {
return '<%=' + _.camelCase(match) + '%>';
}),

View File

@ -11,7 +11,7 @@ api._namespaces = <%= stringify(namespaces) %>;<%
_.each(actions, function (action) {
var namespace = action.location.split('.').shift();
if (_.includes(namespaces, namespace)) {
if (_.include(namespaces, namespace)) {
_.pull(namespaces, namespace);
%>

View File

@ -112,6 +112,7 @@ fs.readdirSync(path.resolve(__dirname)).forEach(function (filename) {
if (name !== 'index') {
templates[name] = _.template(
fs.readFileSync(path.resolve(__dirname, filename), 'utf8'),
null,
{
imports: templateGlobals
}