Commit Graph
2610 Commits
Author SHA1 Message Date
Jordan Harband 0f09d20988 [Tests] nvm_select_lts_from_nvmrc: add unit tests 2026-11-30 18:07:31 -08:00
Jordan Harband f69c4e5e56 [Tests] nvm_resolve_local_alias: add unit tests 2026-11-30 18:07:30 -08:00
Jordan Harband fd1b2e1c08 [Tests] nvm_resolve_alias: add unit tests 2026-11-30 18:07:29 -08:00
Jordan Harband d870148d17 [Tests] nvm_replace_literal: add unit tests 2026-11-30 18:07:29 -08:00
Jordan Harband 28e240de70 [Tests] nvm_prune: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband 318d9eca70 [Tests] nvm_process_parameters: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband e09a43d096 [Tests] nvm_print_formatted_alias: add unit tests 2026-11-30 18:07:28 -08:00
Jordan Harband 87ba950406 [Tests] nvm_only_includes: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband e279879469 [Tests] nvm_npmrc_bad_news_bears: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband 55bdfd19dd [Tests] nvm_npm_global_modules: add unit tests 2026-11-30 18:07:27 -08:00
Jordan Harband 90965e3aae [Tests] nvm_npm: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband d86011bb0b [Tests] nvm_normalize_version: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband 9c71dec09a [Tests] nvm_needs_lts_status: add unit tests 2026-11-30 18:07:26 -08:00
Jordan Harband 9165bf1060 [Tests] nvm_match_version: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband a95fabb521 [Tests] nvm_lts_status_path: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband 72178b2d67 [Tests] nvm_ls_remote_index_tab: add unit tests 2026-11-30 18:07:25 -08:00
Jordan Harband 08763e43ef [Tests] nvm_list_aliases: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband aa20d996b6 [Tests] nvm_is_zsh: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband 4b12bf4a90 [Tests] nvm_is_version_selected: add unit tests 2026-11-30 18:07:24 -08:00
Jordan Harband 866a9d64c3 [Tests] nvm_is_version_or_alias: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband fb17d36f31 [Tests] nvm_is_below_min_version: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband 43a4ea2a12 [Tests] nvm_install_npm_if_needed: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband e27de13dfa [Tests] nvm_grep: add unit tests 2026-11-30 18:07:23 -08:00
Jordan Harband e3cc267387 [Tests] nvm_get_remote_aliases: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband 10dada17da [Tests] nvm_find_nvmrc: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband 0527e34f99 [Tests] nvm_filter_min_versions: add unit tests 2026-11-30 18:07:22 -08:00
Jordan Harband b2ad63095f [Tests] nvm_filter_lts_versions: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 6bdf17fb4d [Tests] nvm_explain_excluded_version: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 300ab22dfb [Tests] nvm_err_with_colors: add unit tests 2026-11-30 18:07:21 -08:00
Jordan Harband 4c227362a4 [Tests] nvm_ensure_lts_status: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband a5eef5568e [Tests] nvm_echo_with_colors: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband 8baffe92e0 [Tests] nvm_cd_root: add unit tests 2026-11-30 18:07:20 -08:00
Jordan Harband 7773328bb5 [Tests] nvm_cache_dir: add unit tests 2026-11-30 18:07:19 -08:00
Jordan Harband c4bb986185 [Tests] nvm_binary_available: add unit tests 2026-11-30 18:07:19 -08:00
Oikantik Basu 74544c12f4 [Fix] nvm install: explain native Windows curl write failures
Refs #3391.
2026-11-24 19:09:58 +05:30
Hridhin Varkey Joseph 41041a99ca [Tests] nvm_check_file_permissions: symlinked directories and cycles are not traversed 2026-11-22 22:41:58 +05:30
thejesh23 35519ec047 [Fix] nvm reinstall-packages: fail when the version is not installed
`nvm reinstall-packages 99` resolved the version to `N/A` and kept going:
it told the user to run `nvm install N/A`,
printed "Reinstalling global packages from N/A..." and exited 0.
Only the case of an installed version excluded by `--only` returned early.

Now any unresolved version prints "Version '99' is not installed." and returns 3,
like `nvm install --reinstall-packages-from=`,
which already requires an installed version.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: thejesh23 <35212698+thejesh23@users.noreply.github.com>
2026-11-22 08:26:23 -08:00
NUAAwqyandJordan Harband a66a5ae5d2 [Fix] nvm.sh: use NVM_-prefixed locals in the sourcing path
Sourcing nvm.sh fails when the caller has made readonly a variable that nvm.sh declares as a local,
such as `readonly VERSION` in a CI build script:
bash rejects the `local`, and dash exits.

Prefix the locals that sourcing and its `nvm use` reach.
The test derives the unprefixed local names from nvm.sh,
so a new collision fails it.

`nvm_install_default_packages` reported an invalid default-packages file by assigning `nvm`'s `EXIT_CODE` without declaring it.
It now declares its own, and `nvm install` uses its return status instead,
except 3, which means npm failed to install the packages and,
as before, does not fail the install.

Fixes #3584

Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-28 06:30:00 +00:00
585b6ec915 [New] add prune command
`nvm prune` uninstalls every version except the newest install per major
(per minor with `--minor`, and always per minor for `v0.x`),
the current version, the `$NVM_DIR/current` symlink target,
and anything an alias resolves to.
It lists what it will remove and asks first;
`--dry-run` only lists, and `--force` skips the prompt.

Co-authored-by: Guillermo Esguerra <gesguerrab@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-02-23 13:21:38 -05:00
Peter Dave Hello eb0c8b95c8 [Tests] Verify explicit make jobs without redundant source builds
Exercise both argument orders and multiple job counts against the existing fake source fixture,
checking the actual build and install make arguments.
Use an isolated offline cache and a conflicting inherited job count to catch regressions that a successful real compilation alone cannot detect.

Keep a real source build with explicit jobs in each installation suite,
but remove the redundant serial compilation and make installation failures and version mismatches fail the test immediately.
2026-11-26 03:13:13 +08:00
Peter Dave HelloandJordan Harband bea27fbe0f [New] bash_completion: complete options and arguments in context
Parse words before the cursor once to offer flags, versions, and aliases
in the positions that accept them. Distinguish install options before
and after the version, and leave run and exec arguments to the shell.

Match local names literally. Account for Readline splitting at `=` and
quoting common prefixes. Give zsh the same candidates as raw strings so
its line editor can match, quote, and close arguments in its own syntax.

Check the offered flags against nvm help and cover argument boundaries,
including the actual arguments submitted by zsh after Tab completion.

Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-25 13:23:26 -08:00
Jordan Harband 3bf6686090 [Robustness] handle an overridden type
A `type` function or alias defined before nvm is sourced
hijacked `nvm_has` and `nvm_command_info`.
`nvm_has` now uses `command -v`;
`nvm_command_info` needs `type`'s output,
so it uses `builtin type` in zsh,
whose `command type` runs an external `type` that can't see shell functions.

Since `command -v` makes dash hash the command,
`nvm_command_info` also parses dash's and ksh's "tracked alias" output.

Fixes #2352.
2020-11-21 13:33:12 -08:00
Mike MilkmanandJordan Harband a858cc3e2f [readme] bash .nvmrc auto-switching: don't bypass another cd function
`cdnvm` calls `command cd`,
which skips any `cd` function defined by another tool,
like the one `rvm` uses to switch ruby versions.

Salvaged from #1066, which predates the README's `cdnvm` snippet.

Co-authored-by: Mike Milkman <mik356ua@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2016-04-19 15:56:45 +03:00
thejesh23 adf35d7697 [Fix] nvm_get_default_packages: ignore leading and trailing blanks
A trailing space (or tab) left by an editor, or an indented line,
in `$NVM_DIR/default-packages` tripped the "multiple space-separated values" check,
so the whole file was rejected and no default packages were installed after `nvm install`,
with an error naming the wrong problem.
Trim blanks around each line before checking it,
as is already done for a trailing `\r`;
a line with two values is still rejected.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: thejesh23 <35212698+thejesh23@users.noreply.github.com>
2026-11-22 08:26:23 -08:00
Jordan Harband 0a6e489837 [actions] WSL: cap jobs at 10 minutes, since a frozen runner otherwise holds one for 45; don't wait on Ubuntu's mirror
About 1.4% of WSL jobs freeze the runner while setup-wsl starts WSL2
(actions/runner-images#14938):
no step ever finishes, no step timeout fires,
and GitHub drops the job as "lost communication" after 45 minutes,
holding up nearly every run.
A job-level `timeout-minutes` is enforced by the server, so it still applies.

Ubuntu's images already ship bash, git, curl, wget and ca-certificates,
so its apt step only upgrades them,
and a slow `archive.ubuntu.com` has stretched that to 30 minutes.
When they are present, give the upgrade a minute and carry on without it;
otherwise retry 3 times with short delays instead of 8 over 10 minutes.
2026-11-23 14:47:07 -08:00
谢骐 ee8fa8dc70 [Fix] install.sh: support .bash_login
Detect it after `.bash_profile`, including in completion setup,
and update related documentation and tests.

Assisted-by: Kimi K3.1 Pro <317908118+kimi-agent-bot@users.noreply.github.com>
2026-11-22 04:14:10 +08:00
Hridhin Varkey Joseph 3f17b84248 [Perf] nvm_alias, nvm_normalize_lts: avoid forks on alias lookup
Resolving `default -> lts/*` at startup walks default -> lts/* -> lts/<name> -> version, and each `nvm_alias` step forked: `$(nvm_normalize_lts)` even when nothing is rewritten, `echo | tr` to check for lowercase, and `$(nvm_version_dir old)` inside `nvm_alias_path`.

- `nvm_alias_path`: use `${NVM_DIR}` directly, as `nvm_version_dir old` does
- `nvm_normalize_lts`: check for uppercase with a `case` pattern instead of `tr`
- `nvm_alias`: only use a subshell for `lts/-N`, the one form that is rewritten

Assisted-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 05:44:45 +00:00
Jordan Harband 9abb216367 [Fix] install.sh: detect the profile from the login shell that ran the installer
`$SHELL` is the account's login shell,
so when a terminal runs a different shell,
like zsh from Terminal's settings without `chsh`,
the installer wrote to the other shell's profile.
Prefer the shell that ran the installer,
but only when it is a login shell,
since a script that runs the installer,
like a bash dotfiles bootstrap,
isn't the user's shell.

Fixes #592.
Closes #611, whose idea this is.
2026-11-22 12:24:35 -08:00
ii1818nn ea0fcdbe16 [readme] Ansible: use ansible_facts.env rather than the deprecated injected ansible_env
Fixes #3784.
2026-11-20 14:53:54 -08:00
Jordan HarbandandCurt J. Sampson f6e169b130 [readme] Docker: improve the "Docker For Development Environment" section
- Add `--name` to `docker run` command to make the container easier to
  manipulate. (This will produce collisions if two developers both try
  this on the same system, but it's not worth a lot of extra
  documentation to try to sort out the few developers who can't figure
  out what's going on from the error messages)

 - Explain better that the current repo and working copy are copied to ~/.nvm/ inside the container

 - Explain that the container is not deleted when you exit, and how to re-enter and delete it

 - General improvements to the language.

Co-authored-by: Curt J. Sampson <cjs@cynic.net>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-20 14:31:22 -08:00