mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-07-18 12:58:21 +08:00
When `nvm install <target>` found that `<target>` was already installed, the post-`nvm use` steps (`--reinstall-packages-from`, default packages, and `--alias`/`--default`) were gated on `[ $EXIT_CODE -ne 0 ]`. Since that branch is only entered when `nvm use` succeeded (EXIT_CODE == 0), those conditions were always false, so the steps were silently skipped. The fresh-install branch correctly uses `-eq 0`; mirror that here so `--reinstall-packages-from` actually migrates global packages (and the alias/default get set) when the target version already exists. Includes a regression test covering the already-installed path. Fixes #3858