Skip to content

Commit a607a7c

Browse files
committed
fix(@angular/cli): skip downloading temp CLI when running ng update without package names
In the case when `ng update` is ran without a package name, an update is not be performed. In this case using the current installed version of the CLI is good enough. Closes angular#24024
1 parent d69f6ec commit a607a7c

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

packages/angular/cli/src/commands/update/cli.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
165165
packageManager.ensureCompatibility();
166166

167167
// Check if the current installed CLI version is older than the latest compatible version.
168-
if (!disableVersionCheck) {
168+
// Skip when running `ng update` without a package name as this will not trigger an actual update.
169+
if (!disableVersionCheck && options.packages?.length) {
169170
const cliVersionToInstall = await this.checkCLIVersion(
170171
options.packages,
171172
options.verbose,
@@ -882,7 +883,7 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
882883
* @returns the version to install or null when there is no update to install.
883884
*/
884885
private async checkCLIVersion(
885-
packagesToUpdate: string[] | undefined,
886+
packagesToUpdate: string[],
886887
verbose = false,
887888
next = false,
888889
): Promise<string | null> {

packages/angular/cli/src/utilities/package-metadata.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,12 @@ export async function getNpmPackageJson(
292292
const { usingYarn = false, verbose = false, registry } = options;
293293
ensureNpmrc(logger, usingYarn, verbose);
294294
const { packument } = await import('pacote');
295-
const resultPromise = packument(packageName, {
295+
const response = packument(packageName, {
296296
fullMetadata: true,
297297
...npmrc,
298298
...(registry ? { registry } : {}),
299299
});
300300

301-
// TODO: find some way to test this
302-
const response = resultPromise.catch((err) => {
303-
logger.warn(err.message || err);
304-
305-
return { requestedName: packageName };
306-
});
307-
308301
npmPackageJsonCache.set(packageName, response);
309302

310303
return response;

0 commit comments

Comments
 (0)