refactor: generateBranchConfig -> ifTypesGroup

This commit is contained in:
Rhys Arkins 2019-04-06 17:51:36 +02:00
parent 634c6d9433
commit c52ac258e8

View file

@ -3,6 +3,17 @@ const { DateTime } = require('luxon');
const semver = require('semver');
const { mergeChildConfig } = require('../../../config');
function ifTypesGroup(depNames, hasGroupName, branchUpgrades) {
return (
depNames.length === 2 &&
!hasGroupName &&
((branchUpgrades[0].depName.startsWith('@types/') &&
branchUpgrades[0].depName.endsWith(branchUpgrades[1].depName)) ||
(branchUpgrades[1].depName.startsWith('@types/') &&
branchUpgrades[1].depName.endsWith(branchUpgrades[0].depName)))
);
}
function generateBranchConfig(branchUpgrades) {
logger.debug(`generateBranchConfig(${branchUpgrades.length})`);
logger.trace({ config: branchUpgrades });
@ -56,13 +67,9 @@ function generateBranchConfig(branchUpgrades) {
// Delete group config regardless of whether it was applied
delete upgrade.group;
delete upgrade.lazyGrouping;
const isTypesGroup =
depNames.length === 2 &&
!hasGroupName &&
((branchUpgrades[0].depName.startsWith('@types/') &&
branchUpgrades[0].depName.endsWith(branchUpgrades[1].depName)) ||
(branchUpgrades[1].depName.startsWith('@types/') &&
branchUpgrades[1].depName.endsWith(branchUpgrades[0].depName)));
const isTypesGroup = ifTypesGroup(depNames, hasGroupName, branchUpgrades);
// istanbul ignore else
if (toVersions.length > 1 && !isTypesGroup) {
logger.debug({ toVersions });