From c52ac258e8b845e5b891d875bd9b67700d8f89b9 Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Sat, 6 Apr 2019 17:51:36 +0200 Subject: [PATCH] refactor: generateBranchConfig -> ifTypesGroup --- lib/workers/repository/updates/generate.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/workers/repository/updates/generate.js b/lib/workers/repository/updates/generate.js index 900a53ace0..0cb74ec441 100644 --- a/lib/workers/repository/updates/generate.js +++ b/lib/workers/repository/updates/generate.js @@ -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 });