Compare commits

...

35 Commits

Author SHA1 Message Date
Jordan Harband
25fa40e7cb v0.31.7 2016-09-02 23:43:04 -07:00
Jordan Harband
6abc36ee4f [Fix] ensure LTS alias dir exists before writing to it.
Fixes #1216
2016-08-29 09:15:57 -07:00
Jordan Harband
68bf93514b [Fix] when originally installed without git, ensure it can be upgraded to use git.
Fixes #1212. Closes #1213.
2016-08-25 00:59:32 -07:00
Jordan Harband
7e18328a88 Merge pull request #1214 from ljharb/shellcheck
[Tests] add `shellcheck`
2016-08-25 01:00:13 -07:00
Jordan Harband
85c5e12710 [Refactor] install.sh: use curlies in a few places. 2016-08-24 00:50:08 -07:00
Jordan Harband
d0180f7eb2 [shellcheck] build from source to get v0.4.4 2016-08-24 00:30:08 -07:00
Jordan Harband
5ba6e748b7 [Tests] run shellcheck in tests. 2016-08-23 23:07:42 -07:00
Jordan Harband
31c68adbcf v0.31.6 2016-08-23 14:36:15 -07:00
Aria Stewart
451b67fe78 Revert %s-formatting for SOURCE_STR when writing to shell profile 2016-08-23 17:32:28 -04:00
Jordan Harband
d179810b25 v0.31.5 2016-08-23 11:12:21 -07:00
Jordan Harband
1ac7e236b1 [New] Add lts/foo support to remote commands.
- `nvm ls-remote`
 - `nvm version-remote`
 - `nvm install`
 - `nvm uninstall`

Document existing support:
 - `nvm use`
 - `nvm exec`
 - `nvm run`

Fixes #1208.
2016-08-23 10:58:00 -07:00
Jordan Harband
681c81ad30 [shellcheck] clean up install.sh 2016-08-23 00:45:38 -07:00
Jordan Harband
2228323c0b [shellcheck] disable intentional violations via comments 2016-08-23 00:31:39 -07:00
Jordan Harband
cbeb654692 [shellcheck] properly quote arguments. 2016-08-23 00:31:36 -07:00
Jordan Harband
24a9c089ff [shellcheck] fix incorrect A && B || C usages. 2016-08-23 00:31:25 -07:00
Jordan Harband
bc4639c1c9 [Docs] add a road map. 2016-08-21 12:11:43 -07:00
Jordan Harband
54cc3a383e [Tests] set -ex options on more tests 2016-08-14 09:48:25 -07:00
Jordan Harband
d3d768adcd Add nvm_get_mirror 2016-08-10 23:09:54 -07:00
Jordan Harband
9c65197b22 Add nvm_get_checksum_alg 2016-08-09 22:24:09 -07:00
Jordan Harband
bd3ca47714 [Fix] nvm unload: ensure all functions are unset 2016-08-11 10:58:16 -07:00
Jordan Harband
ec4efa3ec7 [Refactor] nvm install: remove unused REINSTALL_PACKAGES_FROM argument to inner installation helpers. 2016-08-11 10:42:32 -07:00
Jordan Harband
08cbcf2254 [Fix] when not using xz on merged node versions, use z to extract, not x 2016-08-10 23:26:29 -07:00
Jordan Harband
4aa6902dbe [Refactor] nvm_install_merged_node_binary: reduce nesting, fix var curlies. 2016-08-10 16:57:03 -07:00
Jordan Harband
0678652bd3 [New] nvm ls/nvm ls-remote/nvm alias: add --no-colors 2016-08-09 14:46:19 -07:00
Jordan Harband
206878460c [Refactor] always shift first argument to nvm 2016-08-09 13:33:43 -07:00
Jordan Harband
79270a579c [Refactor] create nvm_list_aliases 2016-08-06 22:33:37 -07:00
Jordan Harband
b6eb565ea1 [Refactor] nvm alias: reorganize so alias listing is done last 2016-08-08 15:50:05 -07:00
Jordan Harband
091c64c7c5 [Refactor] nvm alias: add in ---based argument support. 2016-08-08 13:37:14 -07:00
Jordan Harband
21b8f556b2 [Refactor] nvm alias: use named vars instead of positional args. 2016-08-08 13:21:42 -07:00
Jordan Harband
a3bc4d3e62 [Refactor] nvm alias: shift out the “alias” 2016-08-08 13:18:53 -07:00
Jordan Harband
150ed490d0 [Refactor] use curlies with variables 2016-08-07 23:31:16 -07:00
Peter Dave Hello
364096a3c3 Add trailing newline char to $SOURCE_STR
Line 302/301 `printf "$SOURCE_STR"` is missing a trailing newline char,
while line 281/282 and 285/286 have their own new line char, so I  just
remove the manually added newline char, and add it to the end of the
variable "$SOURCE_STR", so no more manually newline char needed there.
2016-08-05 15:52:01 +08:00
Peter Dave Hello
88fc93a71b Fix nvm dir path in install script, fix #1189 2016-08-05 15:23:09 +08:00
Jordan Harband
f9f140ec13 [Performance] make auto-using faster.
Per https://github.com/creationix/nvm/issues/539#issuecomment-236830764
2016-08-02 00:59:51 -07:00
Luke Childs
f653bdc606 Print shell version on Travis 2016-07-31 21:14:30 +01:00
12 changed files with 701 additions and 449 deletions

View File

@@ -3,17 +3,25 @@ addons:
apt_packages: apt_packages:
- zsh - zsh
- ksh - ksh
cache:
directories:
- $HOME/.stack
before_install: before_install:
- $SHELL --version 2> /dev/null || dpkg -s $SHELL 2> /dev/null || which $SHELL
- curl --version - curl --version
- wget --version - wget --version
- if [ -n "${SHELLCHECK-}" ]; then sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 575159689BEFB442 && echo 'deb http://download.fpcomplete.com/ubuntu precise main' | sudo tee /etc/apt/sources.list.d/fpco.list && sudo apt-get update && sudo apt-get install stack bc -y && stack setup && stack install ShellCheck && shellcheck --version ; fi
install: install:
- (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*) - (mkdir /tmp/urchin && cd /tmp/urchin && curl -s "$(curl -s https://registry.npmjs.com/urchin | grep -Eo '"tarball":\s*"[^"]+"' | tail -n 1 | awk -F\" '{ print $4 }')" -O && tar -x -f urchin*)
- chmod +x /tmp/urchin/package/urchin - chmod +x /tmp/urchin/package/urchin
- '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y' - '[ -z "$WITHOUT_CURL" ] || sudo apt-get remove curl -y'
script: script:
- export PATH=$(echo $PATH | sed 's/::/:/') - export PATH=$(echo $PATH | sed 's/::/:/')
- NVM_DIR=$TRAVIS_BUILD_DIR make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL - export NVM_DIR="${TRAVIS_BUILD_DIR}"
- if [ -n "${SHELLCHECK-}" ]; then shellcheck -s bash nvm.sh && shellcheck -s sh nvm.sh && shellcheck -s dash nvm.sh && shellcheck -s ksh nvm.sh && shellcheck -s bash install.sh ; fi
- if [ -z "${SHELLCHECK-}" ]; then make TEST_SUITE=$TEST_SUITE URCHIN=/tmp/urchin/package/urchin test-$SHELL ; fi
env: env:
- SHELLCHECK=true
- SHELL=bash TEST_SUITE=install_script - SHELL=bash TEST_SUITE=install_script
- SHELL=sh TEST_SUITE=fast - SHELL=sh TEST_SUITE=fast
- SHELL=dash TEST_SUITE=fast - SHELL=dash TEST_SUITE=fast

View File

@@ -37,13 +37,13 @@ Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Instal
To install or update nvm, you can use the [install script][2] using cURL: To install or update nvm, you can use the [install script][2] using cURL:
```sh ```sh
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash
``` ```
or Wget: or Wget:
```sh ```sh
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash
``` ```
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub> <sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>
@@ -160,13 +160,13 @@ In place of a version pointer like "0.10" or "5.0" or "4.2.1", you can use the f
### Long-term support ### Long-term support
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: 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:
- `nvm install --lts` / `nvm install --lts=argon` - `nvm install --lts` / `nvm install --lts=argon` / `nvm install 'lts/*'` / `nvm install lts/argon`
- `nvm uninstall --lts` / `nvm uninstall --lts=argon` - `nvm uninstall --lts` / `nvm uninstall --lts=argon` / `nvm uninstall 'lts/*'` / `nvm uninstall lts/argon`
- `nvm use --lts` / `nvm use --lts=argon` - `nvm use --lts` / `nvm use --lts=argon` / `nvm use 'lts/*'` / `nvm use lts/argon`
- `nvm exec --lts` / `nvm exec --lts=argon` - `nvm exec --lts` / `nvm exec --lts=argon` / `nvm exec 'lts/*'` / `nvm exec lts/argon`
- `nvm run --lts` / `nvm run --lts=argon` - `nvm run --lts` / `nvm run --lts=argon` / `nvm run 'lts/*'` / `nvm run lts/argon`
- `nvm ls-remote --lts` / `nvm ls-remote --lts=argon` - `nvm ls-remote --lts` / `nvm ls-remote --lts=argon` `nvm ls-remote 'lts/*'` / `nvm ls-remote lts/argon`
- `nvm version-remote --lts` / `nvm version-remote --lts=argon` - `nvm version-remote --lts` / `nvm version-remote --lts=argon` / `nvm version-remote 'lts/*'` / `nvm version-remote lts/argon`
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. 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.
@@ -404,7 +404,7 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
```sh ```sh
apk add bash apk add bash
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | /bin/bash wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | /bin/bash
``` ```
The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries. The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries.
@@ -435,7 +435,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658)) If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658))
[1]: https://github.com/creationix/nvm.git [1]: https://github.com/creationix/nvm.git
[2]: https://github.com/creationix/nvm/blob/v0.31.4/install.sh [2]: https://github.com/creationix/nvm/blob/v0.31.7/install.sh
[3]: https://travis-ci.org/creationix/nvm [3]: https://travis-ci.org/creationix/nvm
[Urchin]: https://github.com/scraperwiki/urchin [Urchin]: https://github.com/scraperwiki/urchin
[Fish]: http://fishshell.com [Fish]: http://fishshell.com

9
ROADMAP.md Normal file
View File

@@ -0,0 +1,9 @@
# nvm Road Map
This is a list of the primary features planned for `nvm`:
1. Rewriting installation code paths to support installing `io.js` and `node` `v4+` [from source](https://github.com/creationix/nvm/issues/1188).
- This will include [reusing previously downloaded tarballs](https://github.com/creationix/nvm/issues/1193) that match checksums, which is a nice performance and bandwith bonus.
1. Adding opt-in environment variable support to list, download, and install `node` [release candidates](https://github.com/creationix/nvm/issues/779), and [nightly builds](https://github.com/creationix/nvm/issues/1053).
1. [`nvm update`](https://github.com/creationix/nvm/issues/400): the ability to autoupdate `nvm` itself
1. [v1.0.0](https://github.com/creationix/nvm/milestone/1), including updating the [nvm on npm](https://github.com/creationix/nvm/issues/304) to auto-install nvm properly

View File

@@ -7,11 +7,11 @@ nvm_has() {
} }
nvm_install_dir() { nvm_install_dir() {
echo ${NVM_DIR:-"$HOME/.nvm"} echo "${NVM_DIR:-"$HOME/.nvm"}"
} }
nvm_latest_version() { nvm_latest_version() {
echo "v0.31.4" echo "v0.31.7"
} }
# #
@@ -49,7 +49,7 @@ nvm_node_version() {
nvm_download() { nvm_download() {
if nvm_has "curl"; then if nvm_has "curl"; then
curl -q $* curl -q "$@"
elif nvm_has "wget"; then elif nvm_has "wget"; then
# Emulate curl with wget # Emulate curl with wget
ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \ ARGS=$(echo "$*" | command sed -e 's/--progress-bar /--progress=bar /' \
@@ -58,7 +58,8 @@ nvm_download() {
-e 's/-s /-q /' \ -e 's/-s /-q /' \
-e 's/-o /-O /' \ -e 's/-o /-O /' \
-e 's/-C - /-c /') -e 's/-C - /-c /')
wget $ARGS # shellcheck disable=SC2086
eval wget $ARGS
fi fi
} }
@@ -68,22 +69,38 @@ install_nvm_from_git() {
if [ -d "$INSTALL_DIR/.git" ]; then if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
printf "\r=> " command printf "\r=> "
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || { command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
exit 1 exit 1
} }
else else
# Cloning to $NVM_DIR # Cloning to $INSTALL_DIR
echo "=> Downloading nvm from git to '$INSTALL_DIR'" echo "=> Downloading nvm from git to '$INSTALL_DIR'"
printf "\r=> " command printf "\r=> "
mkdir -p "$INSTALL_DIR" mkdir -p "${INSTALL_DIR}"
command git clone "$(nvm_source)" "$INSTALL_DIR" || { if [ "$(ls -A "${INSTALL_DIR}")" ]; then
echo >&2 "Failed to clone nvm repo. Please report this!" command git init "${INSTALL_DIR}" || {
exit 1 echo >&2 'Failed to initialize nvm repo. Please report this!'
} exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
echo >&2 'Failed to fetch origin with tags. Please report this!'
exit 2
}
else
command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
echo >&2 'Failed to clone nvm repo. Please report this!'
exit 2
}
fi
fi fi
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout --quiet "$(nvm_latest_version)" command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1 command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
@@ -137,12 +154,12 @@ install_nvm_as_script() {
echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'" echo >&2 "Failed to download '$NVM_SOURCE_LOCAL'"
return 1 return 1
} }
nvm_download -s "$NVM_EXEC_SOURCE" -o "$NVM_DIR/nvm-exec" || { nvm_download -s "$NVM_EXEC_SOURCE" -o "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to download '$NVM_EXEC_SOURCE'" echo >&2 "Failed to download '$NVM_EXEC_SOURCE'"
return 2 return 2
} }
chmod a+x "$NVM_DIR/nvm-exec" || { chmod a+x "$INSTALL_DIR/nvm-exec" || {
echo >&2 "Failed to mark '$NVM_DIR/nvm-exec' as executable" echo >&2 "Failed to mark '$INSTALL_DIR/nvm-exec' as executable"
return 3 return 3
} }
} }
@@ -154,8 +171,8 @@ install_nvm_as_script() {
# Otherwise, an empty string is returned # Otherwise, an empty string is returned
# #
nvm_detect_profile() { nvm_detect_profile() {
if [ -n "$PROFILE" -a -f "$PROFILE" ]; then if [ -n "${PROFILE}" ] && [ -f "${PROFILE}" ]; then
echo "$PROFILE" echo "${PROFILE}"
return return
fi fi
@@ -206,18 +223,18 @@ nvm_check_global_modules() {
local NPM_GLOBAL_MODULES local NPM_GLOBAL_MODULES
NPM_GLOBAL_MODULES="$( NPM_GLOBAL_MODULES="$(
npm list -g --depth=0 | npm list -g --depth=0 |
sed '/ npm@/d' | command sed '/ npm@/d' |
sed '/ (empty)$/d' command sed '/ (empty)$/d'
)" )"
local MODULE_COUNT local MODULE_COUNT
MODULE_COUNT="$( MODULE_COUNT="$(
printf %s\\n "$NPM_GLOBAL_MODULES" | command printf %s\\n "$NPM_GLOBAL_MODULES" |
sed -ne '1!p' | # Remove the first line command sed -ne '1!p' | # Remove the first line
wc -l | tr -d ' ' # Count entries wc -l | tr -d ' ' # Count entries
)" )"
if [ $MODULE_COUNT -ne 0 ]; then if [ "${MODULE_COUNT}" != '0' ]; then
cat <<-'END_MESSAGE' cat <<-'END_MESSAGE'
=> You currently have modules installed globally with `npm`. These will no => You currently have modules installed globally with `npm`. These will no
=> longer be linked to the active version of Node when you install a new node => longer be linked to the active version of Node when you install a new node
@@ -225,7 +242,7 @@ nvm_check_global_modules() {
=> override the binaries of modules installed with `nvm`: => override the binaries of modules installed with `nvm`:
END_MESSAGE END_MESSAGE
printf %s\\n "$NPM_GLOBAL_MODULES" command printf %s\\n "$NPM_GLOBAL_MODULES"
cat <<-'END_MESSAGE' cat <<-'END_MESSAGE'
=> If you wish to uninstall them at a later point (or re-install them under your => If you wish to uninstall them at a later point (or re-install them under your
@@ -239,24 +256,24 @@ nvm_check_global_modules() {
} }
nvm_do_install() { nvm_do_install() {
if [ -z "$METHOD" ]; then if [ -z "${METHOD}" ]; then
# Autodetect install method # Autodetect install method
if nvm_has "git"; then if nvm_has git; then
install_nvm_from_git install_nvm_from_git
elif nvm_has "nvm_download"; then elif nvm_has nvm_download; then
install_nvm_as_script install_nvm_as_script
else else
echo >&2 "You need git, curl, or wget to install nvm" echo >&2 'You need git, curl, or wget to install nvm'
exit 1 exit 1
fi fi
elif [ "~$METHOD" = "~git" ]; then elif [ "${METHOD}" = 'git' ]; then
if ! nvm_has "git"; then if ! nvm_has git; then
echo >&2 "You need git to install nvm" echo >&2 "You need git to install nvm"
exit 1 exit 1
fi fi
install_nvm_from_git install_nvm_from_git
elif [ "~$METHOD" = "~script" ]; then elif [ "${METHOD}" = 'script' ]; then
if ! nvm_has "nvm_download"; then if ! nvm_has nvm_download; then
echo >&2 "You need curl or wget to install nvm" echo >&2 "You need curl or wget to install nvm"
exit 1 exit 1
fi fi
@@ -266,31 +283,31 @@ nvm_do_install() {
echo echo
local NVM_PROFILE local NVM_PROFILE
NVM_PROFILE=$(nvm_detect_profile) NVM_PROFILE="$(nvm_detect_profile)"
local INSTALL_DIR local INSTALL_DIR
INSTALL_DIR="$(nvm_install_dir)" INSTALL_DIR="$(nvm_install_dir)"
SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm" SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && . \"\$NVM_DIR/nvm.sh\" # This loads nvm\n"
if [ -z "$NVM_PROFILE" ] ; then if [ -z "${NVM_PROFILE-}" ] ; then
echo "=> Profile not found. Tried $NVM_PROFILE (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile." echo "=> Profile not found. Tried ${NVM_PROFILE} (as defined in \$PROFILE), ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile."
echo "=> Create one of them and run this script again" echo "=> Create one of them and run this script again"
echo "=> Create it (touch $NVM_PROFILE) and run this script again" echo "=> Create it (touch ${NVM_PROFILE}) and run this script again"
echo " OR" echo " OR"
echo "=> Append the following lines to the correct file yourself:" echo "=> Append the following lines to the correct file yourself:"
printf "$SOURCE_STR" command printf "${SOURCE_STR}"
echo
else else
if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then if ! command grep -qc '/nvm.sh' "$NVM_PROFILE"; then
echo "=> Appending source string to $NVM_PROFILE" echo "=> Appending source string to $NVM_PROFILE"
printf "$SOURCE_STR\n" >> "$NVM_PROFILE" command printf "$SOURCE_STR" >> "$NVM_PROFILE"
else else
echo "=> Source string already in $NVM_PROFILE" echo "=> Source string already in ${NVM_PROFILE}"
fi fi
fi fi
# Source nvm # Source nvm
. "$NVM_DIR/nvm.sh" # shellcheck source=/dev/null
. "${INSTALL_DIR}/nvm.sh"
nvm_check_global_modules nvm_check_global_modules
@@ -299,7 +316,7 @@ nvm_do_install() {
nvm_reset nvm_reset
echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:" echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
printf "$SOURCE_STR" command printf "$SOURCE_STR"
} }
# #

936
nvm.sh

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "nvm", "name": "nvm",
"version": "0.31.4", "version": "0.31.7",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": { "directories": {
"test": "test" "test": "test"

View File

@@ -32,6 +32,14 @@ OUTPUT="$(nvm version-remote --lts=argon foo)"
EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:argon,PATTERN:foo' EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:argon,PATTERN:foo'
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote --lts=argon foo\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<" [ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote --lts=argon foo\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"
OUTPUT="$(nvm version-remote lts/foo)"
EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:foo,PATTERN:'
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote lts/foo\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"
OUTPUT="$(nvm version-remote 'lts/*')"
EXPECTED_OUTPUT='NVM_VERSION_ONLY:true,NVM_LTS:*,PATTERN:'
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "\`nvm version-remote lts/*\` called nvm_remote_version with >${OUTPUT}<, expected >${EXPECTED_OUTPUT}<"
set +ex # needed for stderr set +ex # needed for stderr
OUTPUT="$(nvm version-remote --foo bar 2>&1)" OUTPUT="$(nvm version-remote --foo bar 2>&1)"
set -ex set -ex

View File

@@ -0,0 +1,18 @@
#!/bin/sh
set -ex
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
ALG="$(nvm_get_checksum_alg)"
case "$ALG" in
'sha-256' | 'sha-1')
echo 'sha-256 or sha-1 found'
;;
*)
die "sha-256 or sha-1 not found: found ${ALG}"
;;
esac

View File

@@ -0,0 +1,16 @@
#!/bin/sh
set -ex
die () { echo $@ ; exit 1; }
. ../../../nvm.sh
! nvm_get_mirror || die 'unknown release type did not error'
! nvm_get_mirror node || die 'unknown release type did not error'
! nvm_get_mirror iojs || die 'unknown release type did not error'
! nvm_get_mirror node foo || die 'unknown release type did not error'
! nvm_get_mirror iojs foo || die 'unknown release type did not error'
[ "$(nvm_get_mirror node std)" = "${NVM_NODEJS_ORG_MIRROR}" ] || die 'node std did not yield NVM_NODEJS_ORG_MIRROR'
[ "$(nvm_get_mirror iojs std)" = "${NVM_IOJS_ORG_MIRROR}" ] || die 'node std did not yield NVM_NODEJS_ORG_MIRROR'

View File

@@ -1,23 +1,29 @@
#!/bin/sh #!/bin/sh
set -ex
die () { echo $@ ; exit 1; } die () { echo $@ ; exit 1; }
set +e # TODO: fix
. ../../nvm.sh . ../../nvm.sh
set -e
nvm deactivate || die 'deactivate failed'
nvm unalias default || die 'unable to unalias default' nvm unalias default || die 'unable to unalias default'
NVM_TEST_VERSION=v0.10.7 NVM_TEST_VERSION=v0.10.7
# Remove the stuff we're clobbering. # Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION nvm uninstall "${NVM_TEST_VERSION}" || die 'nvm uninstall failed'
# Install from source # Install from source
nvm install -s $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed" nvm install -s "${NVM_TEST_VERSION}" || die "'nvm install -s ${NVM_TEST_VERSION}' failed"
# Check # Check
[ -d ../../$NVM_TEST_VERSION ] [ -d ../../$NVM_TEST_VERSION ] || die "../../${NVM_TEST_VERSION} is not a directory"
nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || "'nvm run ${NVM_TEST_VERSION} --version | grep ${NVM_TEST_VERSION}' failed"
# ensure default is set # ensure default is set
NVM_CURRENT_DEFAULT="$(nvm_alias default)" NVM_CURRENT_DEFAULT="$(nvm_alias default)"
[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)" [ "${NVM_CURRENT_DEFAULT}" = "${NVM_TEST_VERSION}" ] || die "wrong default alias: $(nvm alias)"

View File

@@ -1,13 +1,19 @@
#!/bin/sh #!/bin/sh
set -ex
die () { echo $@ ; exit 1; } die () { echo $@ ; exit 1; }
set +e # TODO: fix
. ../../nvm.sh . ../../nvm.sh
set -e
nvm deactivate || die 'deactivate failed'
NVM_TEST_VERSION=v0.8.5 NVM_TEST_VERSION=v0.8.5
# Remove the stuff we're clobbering. # Remove the stuff we're clobbering.
[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION nvm uninstall "${NVM_TEST_VERSION}" || die 'uninstall failed'
# Install from source implicitly (v0.8.6 is when binaries started) # Install from source implicitly (v0.8.6 is when binaries started)
nvm install $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed" nvm install $NVM_TEST_VERSION || die "'nvm install -s $NVM_TEST_VERSION' failed"

View File

@@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
set -ex
die () { echo $@ ; exit 1; } die () { echo $@ ; exit 1; }
. ../../nvm.sh . ../../nvm.sh