Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25fa40e7cb | ||
|
|
6abc36ee4f | ||
|
|
68bf93514b | ||
|
|
7e18328a88 | ||
|
|
85c5e12710 | ||
|
|
d0180f7eb2 | ||
|
|
5ba6e748b7 | ||
|
|
31c68adbcf | ||
|
|
451b67fe78 | ||
|
|
d179810b25 | ||
|
|
1ac7e236b1 | ||
|
|
681c81ad30 | ||
|
|
2228323c0b | ||
|
|
cbeb654692 | ||
|
|
24a9c089ff | ||
|
|
bc4639c1c9 | ||
|
|
54cc3a383e | ||
|
|
d3d768adcd | ||
|
|
9c65197b22 | ||
|
|
bd3ca47714 | ||
|
|
ec4efa3ec7 | ||
|
|
08cbcf2254 | ||
|
|
4aa6902dbe | ||
|
|
0678652bd3 | ||
|
|
206878460c | ||
|
|
79270a579c | ||
|
|
b6eb565ea1 | ||
|
|
091c64c7c5 | ||
|
|
21b8f556b2 | ||
|
|
a3bc4d3e62 | ||
|
|
150ed490d0 | ||
|
|
364096a3c3 | ||
|
|
88fc93a71b | ||
|
|
f9f140ec13 | ||
|
|
f653bdc606 |
10
.travis.yml
10
.travis.yml
@@ -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
|
||||||
|
|||||||
@@ -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
9
ROADMAP.md
Normal 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
|
||||||
103
install.sh
103
install.sh
@@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
18
test/fast/Unit tests/nvm_get_checksum_alg
Executable file
18
test/fast/Unit tests/nvm_get_checksum_alg
Executable 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
|
||||||
16
test/fast/Unit tests/nvm_get_mirror
Executable file
16
test/fast/Unit tests/nvm_get_mirror
Executable 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'
|
||||||
@@ -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)"
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
die () { echo $@ ; exit 1; }
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|||||||
Reference in New Issue
Block a user