Skip to content

Commit 1deb74f

Browse files
tkruggmgechev
authored andcommitted
fix(@schematics/update): add check for invalid ranges
Fixes #12644 Closes #12806
1 parent 6c0b4db commit 1deb74f

File tree

1 file changed

+7
-4
lines changed
  • packages/schematics/update/update

1 file changed

+7
-4
lines changed

packages/schematics/update/update/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,24 @@ type PeerVersionTransform = string | ((range: string) => string);
3232
// supports 6.0, by adding that compatibility to the range, so it is `^5.0.0 || ^6.0.0`.
3333
// We export it to allow for testing.
3434
export function angularMajorCompatGuarantee(range: string) {
35-
range = semver.validRange(range);
35+
let newRange = semver.validRange(range);
36+
if (!newRange) {
37+
return range;
38+
}
3639
let major = 1;
37-
while (!semver.gtr(major + '.0.0', range)) {
40+
while (!semver.gtr(major + '.0.0', newRange)) {
3841
major++;
3942
if (major >= 99) {
4043
// Use original range if it supports a major this high
4144
// Range is most likely unbounded (e.g., >=5.0.0)
42-
return range;
45+
return newRange;
4346
}
4447
}
4548

4649
// Add the major version as compatible with the angular compatible, with all minors. This is
4750
// already one major above the greatest supported, because we increment `major` before checking.
4851
// We add minors like this because a minor beta is still compatible with a minor non-beta.
49-
let newRange = range;
52+
newRange = range;
5053
for (let minor = 0; minor < 20; minor++) {
5154
newRange += ` || ^${major}.${minor}.0-alpha.0 `;
5255
}

0 commit comments

Comments
 (0)