Skip to content

Commit

Permalink
fix(@angular/cli): disable version check when running ng completion
Browse files Browse the repository at this point in the history
… commands

Running autocompletion with `14.0.1` installed globally in a `14.0.0` project logs the version warning in a very annoying fashion:

```
$ ng verYour global Angular CLI version (14.0.1) is greater than your local version (14.0.0). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
sion
```

This adds an exception for `ng completion` commands to avoid this edge case.

(cherry picked from commit 4f31b57)
  • Loading branch information
alan-agius4 committed Jun 16, 2022
1 parent e5d005b commit b3db91b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/angular/cli/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ let forceExit = false;
console.error('Version mismatch check skipped. Unable to compare local version: ' + error);
}

if (isGlobalGreater) {
const rawCommandName = process.argv[2];
// When using the completion command, don't show the warning as otherwise this will break completion.
if (isGlobalGreater && rawCommandName !== 'completion') {
// If using the update command and the global version is greater, use the newer update command
// This allows improvements in update to be used in older versions that do not have bootstrapping
if (
process.argv[2] === 'update' &&
rawCommandName === 'update' &&
cli.VERSION &&
cli.VERSION.major - globalVersion.major <= 1
) {
Expand Down

0 comments on commit b3db91b

Please sign in to comment.