Skip to content

Commit 28b2cd1

Browse files
alan-agius4clydin
authored andcommitted
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 #24024 (cherry picked from commit 3202410)
1 parent 86b84a8 commit 28b2cd1

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
@@ -164,7 +164,8 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
164164
packageManager.ensureCompatibility();
165165

166166
// Check if the current installed CLI version is older than the latest compatible version.
167-
if (!disableVersionCheck) {
167+
// Skip when running `ng update` without a package name as this will not trigger an actual update.
168+
if (!disableVersionCheck && options.packages?.length) {
168169
const cliVersionToInstall = await this.checkCLIVersion(
169170
options.packages,
170171
options.verbose,
@@ -880,7 +881,7 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
880881
* @returns the version to install or null when there is no update to install.
881882
*/
882883
private async checkCLIVersion(
883-
packagesToUpdate: string[] | undefined,
884+
packagesToUpdate: string[],
884885
verbose = false,
885886
next = false,
886887
): 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)