Skip to content

Commit

Permalink
fix(gradle): handle null tokenizing (#12799)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Nov 23, 2021
1 parent ad9a2f4 commit 3898230
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/versioning/gradle/index.ts
Expand Up @@ -24,7 +24,7 @@ const equals = (a: string, b: string): boolean => compare(a, b) === 0;
const getMajor = (version: string): number | null => {
if (isVersion(version)) {
const tokens = tokenize(version.replace(regEx(/^v/i), ''));
const majorToken = tokens[0];
const majorToken = tokens?.[0];
if (majorToken && majorToken.type === TokenType.Number) {
return +majorToken.val;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/workers/repository/process/lookup/bucket.ts
Expand Up @@ -19,6 +19,10 @@ export function getBucket(
}
const fromMajor = versioning.getMajor(currentVersion);
const toMajor = versioning.getMajor(newVersion);
// istanbul ignore if
if (toMajor === null) {
return null;
}
if (fromMajor !== toMajor) {
if (separateMultipleMajor) {
return `major-${toMajor}`;
Expand Down
11 changes: 7 additions & 4 deletions lib/workers/repository/process/lookup/index.ts
@@ -1,3 +1,4 @@
import is from '@sindresorhus/is';
import { mergeChildConfig } from '../../../../config';
import type { ValidationMessage } from '../../../../config/types';
import { CONFIG_VALIDATION } from '../../../../constants/error-messages';
Expand Down Expand Up @@ -238,10 +239,12 @@ export async function lookupUpdates(
release.version,
versioning
);
if (buckets[bucket]) {
buckets[bucket].push(release);
} else {
buckets[bucket] = [release];
if (is.string(bucket)) {
if (buckets[bucket]) {
buckets[bucket].push(release);
} else {
buckets[bucket] = [release];
}
}
}
const depResultConfig = mergeChildConfig(config, res);
Expand Down

0 comments on commit 3898230

Please sign in to comment.