From b3db91baf50c92589549a66ffef437f7890d3de7 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Thu, 16 Jun 2022 07:25:54 +0000 Subject: [PATCH] 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 4f31b57df36da5230dd247791d0875d60b929035) --- packages/angular/cli/lib/init.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/angular/cli/lib/init.ts b/packages/angular/cli/lib/init.ts index f0620e7a14f8..e4ee414f05e9 100644 --- a/packages/angular/cli/lib/init.ts +++ b/packages/angular/cli/lib/init.ts @@ -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 ) {