Skip to content

Commit

Permalink
fix(@angular/cli): skip downloading temp CLI when running ng update
Browse files Browse the repository at this point in the history
… 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)
  • Loading branch information
alan-agius4 authored and clydin committed Oct 6, 2022
1 parent 86b84a8 commit 28b2cd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/angular/cli/src/commands/update/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
packageManager.ensureCompatibility();

// Check if the current installed CLI version is older than the latest compatible version.
if (!disableVersionCheck) {
// Skip when running `ng update` without a package name as this will not trigger an actual update.
if (!disableVersionCheck && options.packages?.length) {
const cliVersionToInstall = await this.checkCLIVersion(
options.packages,
options.verbose,
Expand Down Expand Up @@ -880,7 +881,7 @@ export class UpdateCommandModule extends CommandModule<UpdateCommandArgs> {
* @returns the version to install or null when there is no update to install.
*/
private async checkCLIVersion(
packagesToUpdate: string[] | undefined,
packagesToUpdate: string[],
verbose = false,
next = false,
): Promise<string | null> {
Expand Down
9 changes: 1 addition & 8 deletions packages/angular/cli/src/utilities/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,12 @@ export async function getNpmPackageJson(
const { usingYarn = false, verbose = false, registry } = options;
ensureNpmrc(logger, usingYarn, verbose);
const { packument } = await import('pacote');
const resultPromise = packument(packageName, {
const response = packument(packageName, {
fullMetadata: true,
...npmrc,
...(registry ? { registry } : {}),
});

// TODO: find some way to test this
const response = resultPromise.catch((err) => {
logger.warn(err.message || err);

return { requestedName: packageName };
});

npmPackageJsonCache.set(packageName, response);

return response;
Expand Down

0 comments on commit 28b2cd1

Please sign in to comment.