Skip to content

Commit b3db91b

Browse files
committed
fix(@angular/cli): disable version check when running ng completion 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)
1 parent e5d005b commit b3db91b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/angular/cli/lib/init.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ let forceExit = false;
7878
console.error('Version mismatch check skipped. Unable to compare local version: ' + error);
7979
}
8080

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

0 commit comments

Comments
 (0)