Commit Graph
45 Commits
Author SHA1 Message Date
NUAAwqyandJordan Harband 7ab48a653b [Fix] nvm_print_implicit_alias: keep STABLE bound, and STABLE and UNSTABLE independent of the caller
`STABLE` is only assigned inside the loop over `LAST_TWO`,
but it is echoed unconditionally afterwards.
With nothing installed, or with only an odd minor,
the loop never runs, so under `set -u` `nvm ls` dies on
`STABLE: unbound variable` instead of resolving `stable` to nothing.

`local STABLE` without an initializer also keeps the caller's value in sh and dash,
so `STABLE=x nvm ls stable` resolves the alias to something that isn't installed.
Initializing it where it is declared fixes both,
the way 139ed9c did for `PATTERN`, `NVM_LTS`, `LTS` and `VERSION`.
`local UNSTABLE` keeps the caller's value the same way,
which its `N/A` fallback doesn't cover, so it is initialized too.

The nounset test now covers the two states that leave `stable` unresolved,
and the caller test that `nvm ls stable` answers the same either way,
and that an outer `UNSTABLE` doesn't become the `unstable` alias.

Co-authored-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-10-29 17:08:50 +00:00
NUAAwqy c8dc8c9b1c [Fix] nvm_ls: treat a version dir with only hidden entries as empty
`nvm_ls` decides whether a version dir is worth searching with `ls -1qA`, which
also counts dotfiles, but then collects versions with `find "${DIR}"/*`, which
never matches them. A dir holding nothing but hidden entries passes the guard,
so when `nullglob` is not set `find` is handed the literal `*` and `nvm ls`
prints "No such file or directory" to stderr.

Drop `-A` from the guard so both halves agree on what counts as an entry.

Fixes #3727.
2026-10-29 16:59:39 +00:00
NUAAwqy c6bf252f7d [Fix] ls: list versions whose directory is a symlink
nvm_ls collects installed versions with `find <dirs>/* -name . -o -type d -prune -o -path ...`,
and `-type d` is false for a symlink,
so a version dir that links to another volume was skipped from the listing entirely
- while `nvm version`, `nvm which` and `nvm use` all kept working on it.

Have that find follow symlinks,
which makes linked-in versions visible and still ignores a broken link.

Fixes #617.
2026-10-29 14:59:29 +00:00
Peter Dave Hello 29a652f90f [patch] show system Node.js version in nvm ls
Normalize `nvm_version` output when `nvm_ls` returns "system vX" so alias and .nvmrc resolutions treat system correctly.

Add fast tests for system alias behavior in `nvm ls`, `nvm use`, and `nvm which`.
2026-01-25 18:19:50 +08:00
Jordan Harband c451e7a4c8 [Tests] set $_ before sourcing nvm.sh in fast tests
nvm.sh uses `NVM_SCRIPT_SOURCE="$_"` to detect its source location.
Adding `: nvm.sh` before each source line ensures `$_` is set correctly, preventing breakage when the previous command (e.g., `set -ex`) overwrites it.
2026-01-26 21:41:57 -08:00
Jordan Harband ce35311657 [Tests] force the NVM_DIR to the expected location, for tests 2022-12-27 21:40:48 -08:00
nmarghetti 9849bf494d [meta] Rename some files to be more cross platform 2021-01-04 00:49:05 +01:00
Dylan Armstrong 96069da0d5 [Fix] nvm_ls: zsh: unset markdirs and local_options
Fixes #2315.
2020-10-09 09:43:21 -05:00
Sehrope Sarkuni 0b5bb5ccd8 [Fix] set -u: Add default empty value for $NVM_NO_ALIAS
Adds a default value for NVM_NO_ALIAS so that nvm ls does not error out when run
in a bash nounset/-u (no unset vars) environment.
2019-05-14 08:31:24 -04:00
Christopher Sahnwaldt a1abfd1fe4 [Tests] use rimraf over rmdir in teardowns
- fix test 'Running "nvm ls" should display all installed versions.': only expect versions created by this test, but no versions created by other tests
2019-02-27 10:50:59 +01:00
Jordan Harband c6740f5a6e [New] nvm ls: add --no-alias to suppress alias output
Per https://github.com/creationix/nvm/issues/1792#issuecomment-466696504
2019-02-23 22:41:46 -08:00
Jordan Harband 04fdb2331b [Tests] nvm ls: ensure nvm alias is called 2019-02-23 22:22:18 -08:00
Jordan Harband 2a513a1bc0 [Fix] nvm_ls: Reverts #1462 to fix io.js sorting.
<details>
<summary>Before this revert:</summary>

```sh
iojs-v3.3.1
iojs-v2.5.0
v0.6.21
v0.7.12
iojs-v1.8.4
v0.8.28
v0.9.12
v0.10.48
v0.11.16
v0.12.9
v0.12.18
v0.12.87
v4.9.1
v5.11.1
v5.12.0
v6.14.4
v6.16.0
v7.10.1
v8.6.0
v8.9.1
v8.10.0
v8.11.3
v8.11.4
v8.12.0
v8.13.0
v8.14.1
v8.15.0
v9.11.2
v10.0.0
v10.1.0
v10.2.1
v10.3.0
v10.4.1
v10.5.0
v10.6.0
v10.7.0
v10.8.0
v10.9.0
v10.10.0
v10.11.0
v10.12.0
v10.13.0
v10.14.2
v10.15.1
v11.0.0
v11.1.0
v11.2.0
v11.3.0
v11.4.0
v11.5.0
v11.6.0
v11.7.0
v11.8.0
v11.9.0
v11.10.0
```
</details>

<details>
<summary>After this revert:</summary>

```sh
v0.6.21
v0.7.12
v0.8.28
v0.9.12
v0.10.48
v0.11.16
v0.12.9
v0.12.18
v0.12.87
iojs-v1.8.4
iojs-v2.5.0
iojs-v3.3.1
v4.9.1
v5.11.1
v5.12.0
v6.14.4
v6.16.0
v7.10.1
v8.6.0
v8.9.1
v8.10.0
v8.11.3
v8.11.4
v8.12.0
v8.13.0
v8.14.1
v8.15.0
v9.11.2
v10.0.0
v10.1.0
v10.2.1
v10.3.0
v10.4.1
v10.5.0
v10.6.0
v10.7.0
v10.8.0
v10.9.0
v10.10.0
v10.11.0
v10.12.0
v10.13.0
v10.14.2
v10.15.1
v11.0.0
v11.1.0
v11.2.0
v11.3.0
v11.4.0
v11.5.0
v11.6.0
v11.7.0
v11.8.0
v11.9.0
v11.10.0
```
</details>

In other words, the sorting needs to happen *before* the `NVM_NODE_PREFIX` is removed.
2019-02-23 15:02:31 -08:00
Joshua Li a5f42d9cea [Tests] update most mkdirs to use make_fake_{node,iojs} 2018-06-13 10:38:19 -07:00
Peter Dave Hello 2cd2c0f72e Remove useless trailing newlines 2018-02-26 01:01:30 +08:00
Jordan Harband dc5dfe3bc1 [Fix] set IFS to default for all nvm commands.
Fixes #1227. Fixes #1244. Fixes #1514. Fixes #1518.
2017-04-28 00:41:55 -07:00
Peter Dave Hello f7763c8ba9 [Tests] die() in tests should quote "$@" for echo 2016-11-07 03:34:36 +08:00
Qiangjun Ran cadbbced20 [Tests] Replace all dots with backslash dots 2016-11-03 23:44:59 -07:00
Jordan Harband 73aa35f508 [Tests] use $NVM_DIR instead of relative paths 2016-06-26 15:52:26 -07:00
Jordan Harband 91c77c6ba8 [Tests] fix shebangs 2016-04-27 17:34:53 -07:00
Jordan Harband 2116d2ff91 Filter out the io.js version dir from nvm_ls output.
Fixes #642.
2015-02-02 17:41:04 -08:00
Jordan Harband 39a75e616d Add support for nvm use node, nvm use iojs, nvm ls node, and nvm ls iojs
Also add `nvm_version node` and `nvm_version iojs` support.
2015-01-18 20:45:02 -06:00
Jordan Harband f661617f1c Make nvm_ls foo work with iojs-prefixed version strings. 2015-01-12 18:16:11 -08:00
Jordan Harband 0ad5a450fe Put node versions >= 0.12 in versions/node instead of just versions 2015-01-14 12:23:06 -08:00
Jordan Harband 0f5997f754 Clean up from some more tests 2014-10-22 18:15:21 -07:00
Jordan Harband 8284cd0f81 Ensuring that there's a stable and unstable version "available" for this test. 2014-10-21 01:02:59 -07:00
Jordan Harband c918e570b6 Add support for nvm ls stable and nvm ls unstable 2014-09-29 00:09:48 -07:00
Jordan Harband be605cb12b Adding a failing test: nvm ls 0.0.x includes v0.0.xy 2014-09-28 10:18:00 -07:00
Jordan Harband 35466187f2 Noting the changed behavior of nvm ls vx.y. to return something useful. 2014-09-16 09:03:48 -07:00
Jordan Harband 15b3e7b6a8 Removing unnecessary cleanup in "Listing Versions" tests. 2014-09-16 09:03:47 -07:00
Jordan Harband 8d05ab63f1 Silencing error output in the "Listing Versions" teardown script. 2014-09-16 09:03:47 -07:00
Jordan Harband a80f958a1e All 4 of these test files should be executable. 2014-09-14 16:03:55 -07:00
Jordan Harband 110e571c34 Make nvm ls system work. 2014-09-05 00:29:20 -07:00
Jordan Harband b59ecb9e11 Make sure the new versions directory is filtered out of nvm_ls output (in zsh). 2014-08-21 23:39:40 -07:00
Jordan Harband 5dd2d7e5d4 Make nvm ls support listing the "versions" directory when it's present. 2014-08-20 00:42:50 -07:00
Jordan Harband 6dc602b521 Ensure that nvm ls node doesn't return "node_modules", for example. 2014-08-01 01:24:28 -07:00
Jordan Harband 6e02e5a54c If nvm_ls is called without a pattern, and node exists, tack on "system". 2014-07-21 02:03:18 -07:00
Jordan Harband 8a29122d0a Adding teardown to test/fast/Listing versions/ 2014-07-15 02:01:01 -07:00
Jordan Harband f6974744cd Moving this nvm ls test inside the "listing versions" test subdir. 2014-07-14 12:36:28 -07:00
Jordan Harband 802f064178 Adding a failing test. 2014-07-12 11:02:14 -07:00
Andrew Crites 1b22c2e2b1 Including test for specific version listing
This fixes the issue of nvm ls v[:digit:].[:digit:].[:digit:] listing the version even if it isn't available
2014-06-12 14:01:26 -04:00
Jordan Harband 578a601b27 Filter out of nvm ls things that start with a dot. Fixes #421, closes #422. 2014-05-20 10:36:12 -07:00
Koen Punt 0b97ee1d2a Failing test for when using nvm ls with v* version 2014-03-18 10:49:44 +01:00
Dr. Kibitz 0f709eafa0 Missed tests 2014-02-18 22:07:25 -08:00
Thomas Levine a27d39139b tests from readme
fast tests

alias

unalias

more alias tests

tests

document testing

warn not to run while testing

chmod +x deactivate

specify the version (commit) of urchin

installation test

run

tests for ls

switch unsetopt to the thing creationix has

rename tests

urchin log

adjust urchin version
2012-10-11 16:12:50 -04:00