Skip to content

Commit 835100c

Browse files
clydinmgechev
authored andcommitted
refactor(@angular/cli): allow update version check to be disabled (#16543)
This allows the CLI version check during update bootstrapping to be disabled via the `NG_DISABLE_VERSION_CHECK` environment variable. This is not considered an officially supported option and is intended mainly for testing/troubleshooting scenarios.
1 parent 84515dc commit 835100c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/angular/cli/commands/update-impl.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ const NG_VERSION_9_POST_MSG = colors.cyan(
4242
'For more info, please see: https://v9.angular.io/guide/updating-to-version-9',
4343
);
4444

45+
/**
46+
* Disable CLI version mismatch checks and forces usage of the invoked CLI
47+
* instead of invoking the local installed version.
48+
*/
49+
const disableVersionCheckEnv = process.env['NG_DISABLE_VERSION_CHECK'];
50+
const disableVersionCheck =
51+
disableVersionCheckEnv !== undefined &&
52+
disableVersionCheckEnv !== '0' &&
53+
disableVersionCheckEnv.toLowerCase() !== 'false';
54+
4555
export class UpdateCommand extends Command<UpdateCommandSchema> {
4656
public readonly allowMissingWorkspace = true;
4757

@@ -264,7 +274,7 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
264274
}
265275

266276
// Check if the current installed CLI version is older than the latest version.
267-
if (await this.checkCLILatestVersion(options.verbose, options.next)) {
277+
if (!disableVersionCheck && await this.checkCLILatestVersion(options.verbose, options.next)) {
268278
this.logger.warn(
269279
`The installed Angular CLI version is older than the latest ${options.next ? 'pre-release' : 'stable'} version.\n` +
270280
'Installing a temporary version to perform the update.',

0 commit comments

Comments
 (0)