Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): calculate valid Angular versions …
Browse files Browse the repository at this point in the history
…from peerDependencies

With this change we update the `assertCompatibleAngularVersion` logic to use `peerDependencies` on `@angular/compiler-cli` listed in the `package.json` to determine if the installed Angular version is supported or not.

This is a fix for:
#21449
https://circleci.com/gh/angular/angular-cli/259835?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link
  • Loading branch information
alan-agius4 authored and filipesilva committed Jul 30, 2021
1 parent 65ea6ea commit c1efaa1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/angular_devkit/build_angular/src/utils/version.ts
Expand Up @@ -58,11 +58,9 @@ export function assertCompatibleAngularVersion(projectRoot: string): void | neve
return;
}

const supportedAngularSemver =
require('../../package.json')['peerDependencies']['@angular/compiler-cli'];
const angularVersion = new SemVer(angularPkgJson['version']);
const cliMajor = new SemVer(angularCliPkgJson['version']).major;
// e.g. CLI 8.0 supports '>=8.0.0 <9.0.0', including pre-releases (next, rcs, snapshots)
// of both 8 and 9.
const supportedAngularSemver = `^${cliMajor}.0.0-next || >=${cliMajor}.0.0 <${cliMajor + 1}.0.0`;

if (!satisfies(angularVersion, supportedAngularSemver, { includePrerelease: true })) {
console.error(
Expand Down

0 comments on commit c1efaa1

Please sign in to comment.