Commit Graph

334 Commits

Author SHA1 Message Date
Bark
01a8749d7f [Fix] nvm exec: Do a version check on nvm-exec
This check would display a message in case the `.nvmrc` version is not installed, and would not alter the output otherwise.
2024-03-06 16:03:10 +02:00
Noritaka Kobayashi
4d364c2e7b [readme] fix typo 2025-10-18 10:28:48 +09:00
Rahul Beniwal
81f13638d7 [Fix] Reject bare LTS codenames in nvm install
Previously, `nvm install Argon` would succeed by matching the LTS name
in the version description (e.g., "v4.9.1 (Latest LTS: Argon)"), but
`nvm uninstall Argon` would fail because "Argon" is not a valid alias or not a valid version.

Changes:
- Added pattern matching check in nvm_remote_version (nvm.sh:785-791)
- Skips check for implicit aliases (node, stable, etc.) to preserve
  existing functionality
- Added unit tests to verify LTS names are rejected while version
  numbers still work
After this fix:
- `nvm install Argon` → fails (use `nvm install lts/argon` instead)
- `nvm install 4` → still works
- `nvm install node` → still works
- `nvm install lts/argon` → still works

This makes install and uninstall behavior consistent.

Fixes #3474.
2025-11-24 21:57:39 +05:30
Jordan Harband
26066c10f4 [Fix] prevent sed errors when pattern contains #
When `.nvmrc` or alias files contained comments (lines with `#`),
the `#` character could end up in the search pattern passed to sed,
causing "unterminated regular expression" errors because `#` is
used as the sed address delimiter.

This commit fixes the issue in two places:
1. `nvm_alias`: Strip comments from alias file contents before
   returning them, and trim trailing whitespace
2. `nvm_ls`: Escape `#` characters in SEARCH_PATTERN so they're
   treated as literal characters in the sed address

Fixes #3761
2026-01-19 22:58:43 -08:00
Jordan Harband
1be4257e96 [Tests] update mocks 2024-10-31 14:23:36 -07:00
Jordan Harband
51ea809d63 [Tests] ensure that unit tests use only mocked LTS names 2024-10-30 23:41:50 -07:00
Jordan Harband
da2720a429 [Fix] nvm ls, nvm alias, nvm install: error when an LTS name is invalid 2024-09-04 13:55:11 -07:00
Jordan Harband
9fb9dec710 [Fix] nvm_normalize_lts: error when an LTS name is not lowercase
Fixes #3417
2024-09-04 13:54:41 -07:00
Jordan Harband
9a28dbd394 [actions] use node/install instead of node/run 2024-08-28 11:28:52 -07:00
Jordan Harband
ff7634577b [Tests] fix broken tests exposed by 863bd63
Leaves 2 non-executable, + some TODOs
2024-08-27 12:46:40 -07:00
Jordan Harband
0ce8f5a52f [Fix] nvm_download: ensure all args are quoted
Fixes #3411.
2024-08-20 22:33:38 -07:00
Jordan Harband
863bd63cfa [Tests] set proper permissions on test files 2024-08-23 17:23:12 -07:00
Jordan Harband
14acd3dcdd [Fix] nvm install -b: do not attempt to download source on a failed binary download with -b
Fixes #3399
2024-08-01 10:35:37 -07:00
Jordan Harband
271720ebfc [Fix] nvm install -b: when no binary is available, fail and output a clear message 2024-08-01 13:57:22 -07:00
Jordan Harband
423ee82b4c [Tests] fix nvm ls-remote unit test 2024-08-01 10:22:28 -07:00
Jordan Harband
87a709741f [Fix] nvm_get_default_packages: use awk for more reliable file processing
See db19450caa

Fixes #3382
2024-07-28 10:02:08 -07:00
Martin
f439acda4a [New] nvm use/nvm install: add --save option
Fixes #2849.

Co-authored-by: Martin <maartin00000@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2022-08-29 16:01:36 +01:00
David Welch
bd090ef7f8 [New] Add support for NVM_AUTH_HEADER env var
Closes #3366

Co-authored-by: David Welch <david@davidwelch.co>
Co-authored-by: Andre Kradolfer <narfdre@gmail.com>
2024-06-21 08:55:22 -06:00
Jordan Harband
4c7d899447 [Tests] ignore travis-ci env vars; improve debug output 2024-07-26 12:04:07 -07:00
Jordan Harband
e597bb208e [Tests] use a better JSON parsing implementation 2024-06-10 11:33:12 -07:00
Jordan Harband
29dce5edfd [New] allow .nvmrc files to support comments
In theory, `npx nvmrc` can now be used to validate an `.nvmrc` file that `nvm` will support. Allowances have been made for future extensibility, and aliases may no longer contain a `#`.

Fixes #3336. Closes #2288.

Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Yash Singh <saiansh2525@gmail.com>
2024-06-07 10:13:00 -07:00
Jordan Harband
b1fa143dd8 [Fix] nvm_get_mirror: ensure only a valid URL is allowed 2023-12-02 14:44:46 -08:00
Jordan Harband
d02ddcac2c [Fix] nvm_get_mirror: disallow some non-URL characters
This should be improved in the future, but is fine for now
2023-11-01 21:01:28 -07:00
Andrius Solopovas
ef7fc2f2c0 [Fix] nvm_get_arch: proper value for alpine linux 2023-09-30 23:54:11 +01:00
Jordan Harband
6743aef70c [New] nvm_resolve_alias: only resolve one line of a multiline alias file 2023-10-23 14:41:14 -07:00
Jordan Harband
10cdda081f [Tests] update test mocks (new LTS, iron) 2023-10-25 15:39:12 -07:00
Jordan Harband
8241287349 [New] aliases: skip leading blank lines in alias file 2023-10-23 14:06:19 -07:00
Jordan Harband
bfce5889f7 [Test] update test mocks 2023-10-23 14:53:39 -07:00
Oliver Henshaw
15eba7b7e6 [Fix] nvm_strip_path: Preserve leading/trailing colons
Path lists in environmental variables often give special meaning to
empty entries (e.g. in PATH or MANPATH). These are represented by
leading or trailing colons, or by doubled colons in the middle of the
list.

Adjust the awk invocation to correctly deal with trailing colons by
printing the separator before every field except the first, and then
printing the final separator that is read from the input - this will
either be a colon or the null string. This preserves leading and
trailing colons in all cases while not adding extra colons in the wrong
place.

Add test to confirm the correct behaviour.

Fixes #3144
2023-06-21 15:47:52 +01:00
Deniz
5410ae57ba [Fix] fix node download link for armv8l
Fixes #3035
2023-04-29 16:41:31 -07:00
Leo Zlotnikov
0d9b5c2a00 [Fix] fix directory traversal when workdir path is not readable 2023-04-08 17:24:41 +01:00
Jordan Harband
b1331c20b0 [Tests] add unit tests for nvm_download_artifact 2023-04-06 09:23:33 -07:00
Jordan Harband
ce35311657 [Tests] force the NVM_DIR to the expected location, for tests 2022-12-27 21:40:48 -08:00
Jordan Harband
788c0a425e [meta] use HEAD instead of master where possible 2022-12-23 12:53:40 -08:00
Jordan Harband
d0bc227127 [Tests] update test mocks 2022-12-22 16:07:00 -08:00
Jordan Harband
4c4b0d64ed [Tests] fix nvm_list_aliases test to use mocks for LTS aliases 2022-10-26 10:31:26 -07:00
Jordan Harband
df01d81128 [Refactor] add nvm_wrap_with_color_code; allow no color code 2022-10-13 20:16:42 -07:00
Jordan Harband
0698ede92d [Tests] update test mocks 2022-10-13 12:08:31 -07:00
deepakchethan
9e884b8d7b [Fix] nvm install: show proper version in .nvmrc install instructions 2022-03-22 18:58:18 +05:30
Bob Bregant II
ccd442d833 [Refactor] add nvm_extract_tarball to consolidate extraction logic 2021-12-19 02:58:18 +00:00
Jordan Harband
5cc74a6736 [Tests] fix failing test 2021-12-17 13:21:29 -08:00
Jordan Harband
c4c7690dec [Fix] ls-remote/install: support lts/-X patterns in installs
Fixes #2692
2021-12-16 23:01:05 -08:00
Jordan Harband
aed1d732d7 [Fix] ls-remote/install: properly handle lts/x patterns 2021-12-16 22:58:06 -08:00
Jordan Harband
0b4cd8df6c [Refactor] create nvm_normalize_lts helper 2021-12-16 22:55:02 -08:00
Jordan Harband
430860a8be [Fix] nvm alias/nvm_list_aliases: support lts/ aliases
See #2692
2021-12-16 15:54:38 -08:00
Jordan Harband
2459d17741 [Tests] update test mocks 2021-12-16 23:13:15 -08:00
Jordan Harband
81fc05684d [Tests] nvm_get_download_slug: add unit tests 2021-12-02 23:33:20 -08:00
Matteo De Wint
93e0070a44 [Fix] nvm_die_on_prefix: filter prefixed env vars on name only, ignoring values 2020-11-28 15:16:35 +01:00
Kaito Udagawa
53f9ba8336 [Refactor] Use awk for path stripping
This works with paths which contains regex meta characters.
2016-12-23 01:03:41 +09:00
Jordan Harband
c169d622ff [Tests] update mocks 2021-09-04 08:57:36 -07:00