Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
31e58d1827 | ||
|
|
a32b914bab | ||
|
|
f51b1bf8ae | ||
|
|
c874a17479 | ||
|
|
6eef4ce4d2 | ||
|
|
54476476ab | ||
|
|
87a3a4425d | ||
|
|
17a3272b8a | ||
|
|
c08010f610 | ||
|
|
2ee8ec886f | ||
|
|
978f7b4435 | ||
|
|
3417e9d9a3 | ||
|
|
eb4de62bc1 | ||
|
|
8a199e00a2 | ||
|
|
6ac7ecf7dc | ||
|
|
a09f225ec7 | ||
|
|
e0e1c0379a | ||
|
|
f4d57cc17d |
@@ -4,6 +4,7 @@ addons:
|
|||||||
- zsh
|
- zsh
|
||||||
- ksh
|
- ksh
|
||||||
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
|
||||||
install:
|
install:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/n
|
|||||||
- [nodist](https://github.com/marcelklehr/nodist)
|
- [nodist](https://github.com/marcelklehr/nodist)
|
||||||
|
|
||||||
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
|
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
|
||||||
- [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell
|
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
||||||
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
||||||
- [fin](https://github.com/fisherman/fin) is a pure fish node version manager for fish shell
|
- [fin](https://github.com/fisherman/fin) is a pure fish node version manager for fish shell
|
||||||
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
|
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
|
||||||
@@ -30,24 +30,29 @@ Note: On OS X, if you have/had a "system" node installed and want to install mod
|
|||||||
|
|
||||||
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
||||||
|
|
||||||
Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm_update` to update.
|
Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
|
||||||
|
|
||||||
### Install script
|
### Install script
|
||||||
|
|
||||||
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.3/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/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>
|
||||||
|
|
||||||
|
```sh
|
||||||
|
export NVM_DIR="$HOME/.nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||||
|
```
|
||||||
|
|
||||||
You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
||||||
Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
||||||
|
|
||||||
@@ -76,16 +81,18 @@ which should output 'nvm' if the installation was successful. Please note that `
|
|||||||
|
|
||||||
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in `~/.nvm`.
|
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in `~/.nvm`.
|
||||||
|
|
||||||
Or if you have `git` installed, then just clone it, and check out the latest version:
|
Or if you have `git` installed (requires git v1.5.5+):
|
||||||
|
|
||||||
|
1. clone this repo
|
||||||
|
1. check out the latest version
|
||||||
|
1. activate nvm by sourcing it from your shell
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
|
export NVM_DIR="$HOME/.nvm" && (
|
||||||
```
|
git clone https://github.com/creationix/nvm.git "$NVM_DIR"
|
||||||
|
cd "$NVM_DIR"
|
||||||
To activate nvm, you need to source it from your shell:
|
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
|
||||||
|
) && . "$NVM_DIR/nvm.sh"
|
||||||
```sh
|
|
||||||
. ~/.nvm/nvm.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
Add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
||||||
@@ -98,16 +105,19 @@ export NVM_DIR="$HOME/.nvm"
|
|||||||
|
|
||||||
### Manual upgrade
|
### Manual upgrade
|
||||||
|
|
||||||
For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version:
|
For manual upgrade with `git` (requires git v1.5.5+):
|
||||||
|
|
||||||
|
1. change to the `$NVM_DIR`
|
||||||
|
1. pull down the latest changes
|
||||||
|
1. check out the latest version
|
||||||
|
1. activate the new version
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd "$NVM_DIR" && git fetch origin && git checkout `git describe --abbrev=0 --tags`
|
(
|
||||||
```
|
cd "$NVM_DIR"
|
||||||
|
git fetch origin
|
||||||
After upgrading, don't forget to activate the new version:
|
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
|
||||||
|
) && . "$NVM_DIR/nvm.sh"
|
||||||
```sh
|
|
||||||
. "$NVM_DIR/nvm.sh"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -150,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.
|
||||||
|
|
||||||
@@ -394,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.3/install.sh | /bin/bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/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.
|
||||||
@@ -425,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.3/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.31.6/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
|
||||||
63
install.sh
63
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.3"
|
echo "v0.31.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -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,15 +69,15 @@ 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" || {
|
command git clone "$(nvm_source)" "$INSTALL_DIR" || {
|
||||||
echo >&2 "Failed to clone nvm repo. Please report this!"
|
echo >&2 "Failed to clone nvm repo. Please report this!"
|
||||||
@@ -103,7 +104,6 @@ nvm_install_node() {
|
|||||||
NODE_VERSION="$(nvm_node_version)"
|
NODE_VERSION="$(nvm_node_version)"
|
||||||
|
|
||||||
if [ -z "$NODE_VERSION" ]; then
|
if [ -z "$NODE_VERSION" ]; then
|
||||||
echo "=> You can now install Node.js by running \`nvm install\`"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -138,12 +138,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,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
|
||||||
|
|
||||||
@@ -207,18 +207,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
|
||||||
@@ -226,7 +226,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
|
||||||
@@ -267,37 +267,40 @@ 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
|
||||||
|
|
||||||
# Sourcing $PROFILE to take into account the new environment
|
# Source nvm
|
||||||
. "$NVM_PROFILE"
|
# shellcheck source=/dev/null
|
||||||
|
. "${INSTALL_DIR}/nvm.sh"
|
||||||
|
|
||||||
nvm_check_global_modules
|
nvm_check_global_modules
|
||||||
|
|
||||||
nvm_install_node
|
nvm_install_node
|
||||||
|
|
||||||
nvm_reset
|
nvm_reset
|
||||||
|
|
||||||
|
echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
|
||||||
|
command printf "$SOURCE_STR"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.31.3",
|
"version": "0.31.6",
|
||||||
"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
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ setup_mock_arch() {
|
|||||||
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
||||||
if [ "_$OPT" != "_no_pkg_info" ]; then
|
if [ "_$OPT" != "_no_pkg_info" ]; then
|
||||||
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
||||||
|
else
|
||||||
|
ln -sf "${MOCKS_DIR}/pkg_info_fail" ./pkg_info
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
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 +1,4 @@
|
|||||||
|
# On SmartOS 64bits setups, pkg_info outputs _both_ i386 and x86_64
|
||||||
|
# architectures as architectures supported by pkg_install.
|
||||||
|
echo "i386"
|
||||||
echo "x86_64"
|
echo "x86_64"
|
||||||
|
|||||||
1
test/mocks/pkg_info_fail
Executable file
1
test/mocks/pkg_info_fail
Executable file
@@ -0,0 +1 @@
|
|||||||
|
exit 1
|
||||||
@@ -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