[New] Add `lts/foo` support to remote commands.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
- `nvm ls-remote` - `nvm version-remote` - `nvm install` - `nvm uninstall` Document existing support: - `nvm use` - `nvm exec` - `nvm run` Fixes #1208.
authored by Jordan Harband · committed by Jordan Harband · parent 681c81a · Browse files · 3 files·+60 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+60 added−15 removed
- tests:+8 added−0 removed
- other:+52 added−15 removed
Provenance
- Commit
1ac7e23- Tree
0999e37- Author
Jordan Harband <ljharb@gmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
681c81a
3 files changed+60 added−15 removed
modified:test/fast/Unit tests/nvm version-remote+8 added
30 unmodified lines31 OUTPUT="$(nvm version-remote --lts=argon foo)"32 EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:argon,PATTERN:foo'33 [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote --lts=argon foo\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"34 35+OUTPUT="$(nvm version-remote lts/foo)"36+EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:foo,PATTERN:'37+[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote lts/foo\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"38+39+OUTPUT="$(nvm version-remote 'lts/*')"40+EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:*,PATTERN:'41+[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote lts/*\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"42+43 set +ex # needed for stderr44 OUTPUT="$(nvm version-remote --foo bar 2>&1)"45 set -ex46 EXPECTED_OUTPUT='Unsupported option "--foo".'5 unmodified linesmodified:nvm.sh+45 added-8 removed
2064 unmodified lines2065 elif [ $# -gt 0 ]; then2066 shift2067 fi2068 2069- VERSION="$(NVM_VERSION_ONLY=true NVM_LTS="${LTS-}" nvm_remote_version "$provided_version")"2069+ case "${provided_version}" in2070+ 'lts/*')2071+ LTS='*'2072+ provided_version=''2073+ ;;2074+ lts/*)2075+ LTS="${provided_version##lts/}"2076+ provided_version=''2077+ ;;2078+ esac2079 2080+ VERSION="$(NVM_VERSION_ONLY=true NVM_LTS="${LTS-}" nvm_remote_version "${provided_version}")"2081+2082 if [ "_$VERSION" = "_N/A" ]; then2083 local LTS_MSG2084 local REMOTE_CMD2085 if [ "${LTS-}" = '*' ]; then124 unmodified lines2210 local PATTERN2211 PATTERN="${1-}"2212 case "${PATTERN-}" in2213 --) ;;2203- --lts)2214+ --lts | 'lts/*')2215 VERSION="$(nvm_match_version "lts/*")"2216 ;;2217+ lts/*)2218+ VERSION="$(nvm_match_version "lts/${PATTERN##lts/}")"2219+ ;;2220 --lts=*)2221 VERSION="$(nvm_match_version "lts/${PATTERN##--lts=}")"2222 ;;2223 *)403 unmodified lines2627 while [ $# -gt 0 ]2628 do2629 case "${1-}" in2630 --) ;;2617- --lts) LTS='*' ;;2631+ --lts)2632+ LTS='*'2633+ NVM_FLAVOR="${NVM_NODE_PREFIX}"2634+ ;;2635 --lts=*)2636 LTS="${1##--lts=}"2637 NVM_FLAVOR="${NVM_NODE_PREFIX}"2638 ;;2 unmodified lines2641 nvm_err "Unsupported option \"${1}\"."2642 return 55;2643 ;;2644 *)2628- if [ -z "$PATTERN" ]; then2645+ if [ -z "${PATTERN-}" ]; then2646 PATTERN="${1-}"2630- if [ -z "$NVM_FLAVOR" ]; then2631- case "_$PATTERN" in2632- "_$NVM_IOJS_PREFIX" | "_$NVM_NODE_PREFIX")2633- NVM_FLAVOR="$PATTERN"2647+ if [ -z "${NVM_FLAVOR-}" ]; then2648+ case "${PATTERN}" in2649+ "${NVM_IOJS_PREFIX}" | "${NVM_NODE_PREFIX}")2650+ NVM_FLAVOR="${PATTERN}"2651 PATTERN=""2652 ;;2653+ 'lts/*')2654+ LTS='*'2655+ PATTERN=''2656+ NVM_FLAVOR="${NVM_NODE_PREFIX}"2657+ ;;2658+ lts/*)2659+ LTS="${PATTERN##lts/}"2660+ PATTERN=''2661+ NVM_FLAVOR="${NVM_NODE_PREFIX}"2662+ ;;2663 esac2664 fi2665 fi2666 ;;238 unmodified lines2905 ;;2906 esac2907 shift2908 done2909+ case "${PATTERN}" in2910+ 'lts/*')2911+ NVM_LTS='*'2912+ unset PATTERN2913+ ;;2914+ lts/*)2915+ NVM_LTS="${PATTERN##lts/}"2916+ unset PATTERN2917+ ;;2918+ esac2919 NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"2920 ;;2921 "--version" )2922 nvm_echo '0.31.4'96 unmodified linesmodified:README.markdown+7 added-7 removed
158 unmodified lines159 - `unstable`: this alias points to `node` `v0.11` - the last "unstable" node release, since post-1.0, all node versions are stable. (in semver, versions communicate breakage, not stability).160 161 ### Long-term support162 Node has a [schedule](https://github.com/nodejs/LTS#lts_schedule) for long-term support (LTS) You can reference LTS versions in aliases and `.nvmrc` files with the notation `lts/*` for the latest LTS, and `lts/argon` for LTS releases from the "argon" line, for example. In addition, the following commands support LTS arguments:163- - `nvm install --lts` / `nvm install --lts=argon`164- - `nvm uninstall --lts` / `nvm uninstall --lts=argon`165- - `nvm use --lts` / `nvm use --lts=argon`166- - `nvm exec --lts` / `nvm exec --lts=argon`167- - `nvm run --lts` / `nvm run --lts=argon`168- - `nvm ls-remote --lts` / `nvm ls-remote --lts=argon`169- - `nvm version-remote --lts` / `nvm version-remote --lts=argon`163+ - `nvm install --lts` / `nvm install --lts=argon` / `nvm install 'lts/*'` / `nvm install lts/argon`164+ - `nvm uninstall --lts` / `nvm uninstall --lts=argon` / `nvm uninstall 'lts/*'` / `nvm uninstall lts/argon`165+ - `nvm use --lts` / `nvm use --lts=argon` / `nvm use 'lts/*'` / `nvm use lts/argon`166+ - `nvm exec --lts` / `nvm exec --lts=argon` / `nvm exec 'lts/*'` / `nvm exec lts/argon`167+ - `nvm run --lts` / `nvm run --lts=argon` / `nvm run 'lts/*'` / `nvm run lts/argon`168+ - `nvm ls-remote --lts` / `nvm ls-remote --lts=argon` `nvm ls-remote 'lts/*'` / `nvm ls-remote lts/argon`169+ - `nvm version-remote --lts` / `nvm version-remote --lts=argon` / `nvm version-remote 'lts/*'` / `nvm version-remote lts/argon`170 171 Any time your local copy of `nvm` connects to https://nodejs.org, it will re-create the appropriate local aliases for all available LTS lines. These aliases (stored under `$NVM_DIR/alias/lts`), are managed by `nvm`, and you should not modify, remove, or create these files - expect your changes to be undone, and expect meddling with these files to cause bugs that will likely not be supported.172 173 ### Migrating global packages while installing268 unmodified lines