Repository navigation
fix(@angular/cli): keep ng version working when the package manager is not installed - #34306
Conversation
…s not installed `getVersion()` throws when configured package manager is missing, so `ng version` crashed insted of printing `<error>` Version is left undefined now, same as analytics in command-module.ts
There was a problem hiding this comment.
Code Review
This pull request updates the gatherVersionInfo function to gracefully handle errors when retrieving the package manager version, preventing failures if the package manager is not installed or available. It also introduces corresponding unit tests to verify this behavior. The review feedback suggests a more concise and idiomatic approach using .catch(() => undefined) to avoid a verbose try/catch block and allow declaring the version variable as a const.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
What is the current behavior?
Issue Number: N/A
Workspace with
bun.lockand nobunin PATH, on 22.2.2:ng version --jsonfails same way, exit code 127gatherVersionInfoawaitspackageManager.getVersion(), which rethrows factory'sinitializationErrorwhen binary is missingRenderer still falls back to
<error>andVersionInfotypes field asstring | undefined, so this looks like leftover from f712361, where nullablepackageManager.versionwas swaped for throwinggetVersion()What is the new behavior?
Version lookup is wrapped in try/catch, same as #32929 did for analytics in
command-module.ts, song versionprintsbun <error>and--jsonleavesversionoutNew
version-info_spec.tsdrives realPackageManagerwithinitializationError, its bun case fails on mainDoes this PR introduce a breaking change?
Other information
Patched installed 22.2.2 same way, both commands exit 0 now