Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ad6d98ced | ||
|
|
fa9c50520d | ||
|
|
4846d57c69 | ||
|
|
65f0572bdc | ||
|
|
b6a7a54d04 | ||
|
|
8a8dcbb393 | ||
|
|
bacdd95591 | ||
|
|
4b0563093c | ||
|
|
c7ac69bfbb | ||
|
|
a57fe846e8 | ||
|
|
7bfd1e0644 | ||
|
|
9352f6913a | ||
|
|
16d3e6d2dc | ||
|
|
91a29c0da2 | ||
|
|
4b48556e92 | ||
|
|
be171bba33 | ||
|
|
049a86022f | ||
|
|
a7b7eec0c5 | ||
|
|
9953a52afb | ||
|
|
fc30e0ade4 |
16
README.md
16
README.md
@@ -1,4 +1,4 @@
|
|||||||
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
# Node Version Manager [][3] [][4] [](https://bestpractices.coreinfrastructure.org/projects/684)
|
||||||
|
|
||||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
@@ -41,13 +41,13 @@
|
|||||||
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.33.6/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
or Wget:
|
or Wget:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/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>
|
||||||
@@ -127,7 +127,7 @@ If you have `git` installed (requires git v1.7+):
|
|||||||
|
|
||||||
1. clone this repo in the root of your user profile
|
1. clone this repo in the root of your user profile
|
||||||
- `cd ~/` from anywhere then `git clone https://github.com/creationix/nvm.git .nvm`
|
- `cd ~/` from anywhere then `git clone https://github.com/creationix/nvm.git .nvm`
|
||||||
2. `cd ~/.nvm` and check out the latest version with `git checkout v0.33.6`
|
2. `cd ~/.nvm` and check out the latest version with `git checkout v0.33.8`
|
||||||
3. activate nvm by sourcing it from your shell: `. nvm.sh`
|
3. activate nvm by sourcing it from your shell: `. nvm.sh`
|
||||||
|
|
||||||
Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
||||||
@@ -325,7 +325,7 @@ NVM_IOJS_ORG_MIRROR=https://iojs.org/dist nvm install iojs-v1.0.3
|
|||||||
### .nvmrc
|
### .nvmrc
|
||||||
|
|
||||||
You can create a `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
You can create a `.nvmrc` file containing version number in the project root directory (or any parent directory).
|
||||||
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied.
|
`nvm use`, `nvm install`, `nvm exec`, `nvm run`, and `nvm which` will all respect an `.nvmrc` file when a version is not supplied on the command line.
|
||||||
|
|
||||||
For example, to make nvm default to the latest 5.9 release for the current directory:
|
For example, to make nvm default to the latest 5.9 release for the current directory:
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
|
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
|
||||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | 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.
|
||||||
@@ -554,8 +554,8 @@ sudo chmod ugo-x /usr/libexec/path_helper
|
|||||||
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
More on this issue in [dotphiles/dotzsh](https://github.com/dotphiles/dotzsh#mac-os-x).
|
||||||
|
|
||||||
[1]: https://github.com/creationix/nvm.git
|
[1]: https://github.com/creationix/nvm.git
|
||||||
[2]: https://github.com/creationix/nvm/blob/v0.33.6/install.sh
|
[2]: https://github.com/creationix/nvm/blob/v0.33.8/install.sh
|
||||||
[3]: https://travis-ci.org/creationix/nvm
|
[3]: https://travis-ci.org/creationix/nvm
|
||||||
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.6
|
[4]: https://github.com/creationix/nvm/releases/tag/v0.33.8
|
||||||
[Urchin]: https://github.com/scraperwiki/urchin
|
[Urchin]: https://github.com/scraperwiki/urchin
|
||||||
[Fish]: http://fishshell.com
|
[Fish]: http://fishshell.com
|
||||||
|
|||||||
18
install.sh
18
install.sh
@@ -11,7 +11,7 @@ nvm_install_dir() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nvm_latest_version() {
|
nvm_latest_version() {
|
||||||
echo "v0.33.6"
|
echo "v0.33.8"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_profile_is_bash_or_zsh() {
|
nvm_profile_is_bash_or_zsh() {
|
||||||
@@ -140,22 +140,22 @@ install_nvm_from_git() {
|
|||||||
# Automatically install Node.js
|
# Automatically install Node.js
|
||||||
#
|
#
|
||||||
nvm_install_node() {
|
nvm_install_node() {
|
||||||
local NODE_VERSION
|
local NODE_VERSION_LOCAL
|
||||||
NODE_VERSION="$(nvm_node_version)"
|
NODE_VERSION_LOCAL="$(nvm_node_version)"
|
||||||
|
|
||||||
if [ -z "$NODE_VERSION" ]; then
|
if [ -z "$NODE_VERSION_LOCAL" ]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=> Installing Node.js version $NODE_VERSION"
|
echo "=> Installing Node.js version $NODE_VERSION_LOCAL"
|
||||||
nvm install "$NODE_VERSION"
|
nvm install "$NODE_VERSION_LOCAL"
|
||||||
local CURRENT_NVM_NODE
|
local CURRENT_NVM_NODE
|
||||||
|
|
||||||
CURRENT_NVM_NODE="$(nvm_version current)"
|
CURRENT_NVM_NODE="$(nvm_version current)"
|
||||||
if [ "$(nvm_version "$NODE_VERSION")" == "$CURRENT_NVM_NODE" ]; then
|
if [ "$(nvm_version "$NODE_VERSION_LOCAL")" == "$CURRENT_NVM_NODE" ]; then
|
||||||
echo "=> Node.js version $NODE_VERSION has been successfully installed"
|
echo "=> Node.js version $NODE_VERSION_LOCAL has been successfully installed"
|
||||||
else
|
else
|
||||||
echo >&2 "Failed to install Node.js $NODE_VERSION"
|
echo >&2 "Failed to install Node.js $NODE_VERSION_LOCAL"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
64
nvm.sh
64
nvm.sh
@@ -13,13 +13,7 @@
|
|||||||
NVM_SCRIPT_SOURCE="$_"
|
NVM_SCRIPT_SOURCE="$_"
|
||||||
|
|
||||||
nvm_echo() {
|
nvm_echo() {
|
||||||
command printf %s\\n "$*" 2>/dev/null || {
|
command printf %s\\n "$*" 2>/dev/null
|
||||||
nvm_echo() {
|
|
||||||
# shellcheck disable=SC1001
|
|
||||||
\printf %s\\n "$*" # on zsh, `command printf` sometimes fails
|
|
||||||
}
|
|
||||||
nvm_echo "$@"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_cd() {
|
nvm_cd() {
|
||||||
@@ -212,13 +206,13 @@ nvm_install_latest_npm() {
|
|||||||
NVM_IS_4_4_OR_BELOW=1
|
NVM_IS_4_4_OR_BELOW=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $NVM_IS_4_4_OR_BELOW -eq 1 || (\
|
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || (\
|
||||||
nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 5.0.0 \
|
nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 5.0.0 \
|
||||||
&& nvm_version_greater 5.10.0 "${NODE_VERSION}"\
|
&& nvm_version_greater 5.10.0 "${NODE_VERSION}"\
|
||||||
); then
|
); then
|
||||||
nvm_echo '* `npm` `v5.3.x` is the last version that works on `node` 4.x versions below v4.4, or 5.x versions below v5.10, due to `Buffer.alloc`'
|
nvm_echo '* `npm` `v5.3.x` is the last version that works on `node` 4.x versions below v4.4, or 5.x versions below v5.10, due to `Buffer.alloc`'
|
||||||
$NVM_NPM_CMD install -g npm@5.3
|
$NVM_NPM_CMD install -g npm@5.3
|
||||||
elif $NVM_IS_4_4_OR_BELOW -eq 0 && nvm_version_greater 4.7.0 "${NODE_VERSION}"; then
|
elif [ $NVM_IS_4_4_OR_BELOW -eq 0 ] && nvm_version_greater 4.7.0 "${NODE_VERSION}"; then
|
||||||
nvm_echo '* `npm` `v5.4.x` is the last version that works on `node` `v4.5` and `v4.6`'
|
nvm_echo '* `npm` `v5.4.x` is the last version that works on `node` `v4.5` and `v4.6`'
|
||||||
$NVM_NPM_CMD install -g npm@5.4
|
$NVM_NPM_CMD install -g npm@5.4
|
||||||
else
|
else
|
||||||
@@ -273,12 +267,12 @@ nvm_tree_contains_path() {
|
|||||||
|
|
||||||
# Traverse up in directory tree to find containing folder
|
# Traverse up in directory tree to find containing folder
|
||||||
nvm_find_up() {
|
nvm_find_up() {
|
||||||
local path
|
local path_
|
||||||
path="${PWD}"
|
path_="${PWD}"
|
||||||
while [ "${path}" != "" ] && [ ! -f "${path}/${1-}" ]; do
|
while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
|
||||||
path=${path%/*}
|
path_=${path_%/*}
|
||||||
done
|
done
|
||||||
nvm_echo "${path}"
|
nvm_echo "${path_}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -514,6 +508,7 @@ nvm_remote_versions() {
|
|||||||
local NVM_LS_REMOTE_IOJS_EXIT_CODE
|
local NVM_LS_REMOTE_IOJS_EXIT_CODE
|
||||||
NVM_LS_REMOTE_IOJS_EXIT_CODE=0
|
NVM_LS_REMOTE_IOJS_EXIT_CODE=0
|
||||||
local NVM_LS_REMOTE_IOJS_OUTPUT
|
local NVM_LS_REMOTE_IOJS_OUTPUT
|
||||||
|
NVM_LS_REMOTE_IOJS_OUTPUT=''
|
||||||
if [ -z "${NVM_LTS-}" ] && ( \
|
if [ -z "${NVM_LTS-}" ] && ( \
|
||||||
[ -z "${NVM_FLAVOR-}" ] || [ "${NVM_FLAVOR-}" = "${NVM_IOJS_PREFIX}" ] \
|
[ -z "${NVM_FLAVOR-}" ] || [ "${NVM_FLAVOR-}" = "${NVM_IOJS_PREFIX}" ] \
|
||||||
); then
|
); then
|
||||||
@@ -2116,19 +2111,35 @@ nvm_die_on_prefix() {
|
|||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${PREFIX-}" ] && ! (nvm_tree_contains_path "$NVM_DIR" "$PREFIX" >/dev/null 2>&1); then
|
# npm first looks at $PREFIX (case-sensitive)
|
||||||
|
# we do not bother to test the value here; if this env var is set, unset it to continue.
|
||||||
|
if [ -n "${PREFIX-}" ]; then
|
||||||
nvm deactivate >/dev/null 2>&1
|
nvm deactivate >/dev/null 2>&1
|
||||||
nvm_err "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"$PREFIX\""
|
nvm_err "nvm is not compatible with the \"PREFIX\" environment variable: currently set to \"${PREFIX}\""
|
||||||
nvm_err 'Run `unset PREFIX` to unset it.'
|
nvm_err 'Run `unset PREFIX` to unset it.'
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${NPM_CONFIG_PREFIX-}" ] && ! (nvm_tree_contains_path "$NVM_DIR" "$NPM_CONFIG_PREFIX" >/dev/null 2>&1); then
|
# npm normalizes NPM_CONFIG_-prefixed env vars
|
||||||
nvm deactivate >/dev/null 2>&1
|
# https://github.com/npm/npmconf/blob/22827e4038d6eebaafeb5c13ed2b92cf97b8fb82/npmconf.js#L331-L348
|
||||||
nvm_err "nvm is not compatible with the \"NPM_CONFIG_PREFIX\" environment variable: currently set to \"$NPM_CONFIG_PREFIX\""
|
# https://github.com/npm/npm/blob/5e426a78ca02d0044f8dd26e0c5f881217081cbd/lib/config/core.js#L343-L359
|
||||||
nvm_err 'Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
#
|
||||||
return 4
|
# here, we avoid trying to replicate "which one wins" or testing the value; if any are defined, it errors
|
||||||
elif ! nvm_has 'npm'; then
|
# until none are left.
|
||||||
|
local NVM_NPM_CONFIG_PREFIX_ENV
|
||||||
|
NVM_NPM_CONFIG_PREFIX_ENV="$(command env | nvm_grep -i NPM_CONFIG_PREFIX | command tail -1 | command awk -F '=' '{print $1}')"
|
||||||
|
if [ -n "${NVM_NPM_CONFIG_PREFIX_ENV-}" ]; then
|
||||||
|
local NVM_CONFIG_VALUE
|
||||||
|
eval "NVM_CONFIG_VALUE=\"\$${NVM_NPM_CONFIG_PREFIX_ENV}\""
|
||||||
|
if [ -n "${NVM_CONFIG_VALUE-}" ]; then
|
||||||
|
nvm deactivate >/dev/null 2>&1
|
||||||
|
nvm_err "nvm is not compatible with the \"${NVM_NPM_CONFIG_PREFIX_ENV}\" environment variable: currently set to \"${NVM_CONFIG_VALUE}\""
|
||||||
|
nvm_err "Run \`unset ${NVM_NPM_CONFIG_PREFIX_ENV}\` to unset it."
|
||||||
|
return 4
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! nvm_has 'npm'; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -2363,9 +2374,9 @@ nvm() {
|
|||||||
local DIR
|
local DIR
|
||||||
DIR="$(nvm_cache_dir)"
|
DIR="$(nvm_cache_dir)"
|
||||||
if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
|
if command rm -rf "${DIR}" && command mkdir -p "${DIR}"; then
|
||||||
nvm_echo 'Cache cleared.'
|
nvm_echo 'nvm cache cleared.'
|
||||||
else
|
else
|
||||||
nvm_err "Unable to clear cache: ${DIR}"
|
nvm_err "Unable to clear nvm cache: ${DIR}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -2907,6 +2918,7 @@ nvm() {
|
|||||||
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
command rm -f "$NVM_DIR/current" && ln -s "$NVM_VERSION_DIR" "$NVM_DIR/current"
|
||||||
fi
|
fi
|
||||||
local NVM_USE_OUTPUT
|
local NVM_USE_OUTPUT
|
||||||
|
NVM_USE_OUTPUT=''
|
||||||
if [ $NVM_USE_SILENT -ne 1 ]; then
|
if [ $NVM_USE_SILENT -ne 1 ]; then
|
||||||
if nvm_is_iojs_version "$VERSION"; then
|
if nvm_is_iojs_version "$VERSION"; then
|
||||||
NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"
|
NVM_USE_OUTPUT="Now using io.js $(nvm_strip_iojs_prefix "$VERSION")$(nvm_print_npm_version)"
|
||||||
@@ -3346,7 +3358,7 @@ nvm() {
|
|||||||
;;
|
;;
|
||||||
"clear-cache" )
|
"clear-cache" )
|
||||||
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null
|
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null
|
||||||
nvm_echo 'Cache cleared.'
|
nvm_echo 'nvm cache cleared.'
|
||||||
;;
|
;;
|
||||||
"version" )
|
"version" )
|
||||||
nvm_version "${1}"
|
nvm_version "${1}"
|
||||||
@@ -3387,7 +3399,7 @@ nvm() {
|
|||||||
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
|
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
|
||||||
;;
|
;;
|
||||||
"--version" )
|
"--version" )
|
||||||
nvm_echo '0.33.6'
|
nvm_echo '0.33.8'
|
||||||
;;
|
;;
|
||||||
"unload" )
|
"unload" )
|
||||||
nvm deactivate >/dev/null 2>&1
|
nvm deactivate >/dev/null 2>&1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nvm",
|
"name": "nvm",
|
||||||
"version": "0.33.6",
|
"version": "0.33.8",
|
||||||
"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"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -ex
|
set -eux
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
unset -f nvm_has_system_node nvm_print_npm_version
|
unset -f nvm_has_system_node nvm_print_npm_version
|
||||||
|
|||||||
@@ -46,17 +46,24 @@ OUTPUT="$(nvm_die_on_prefix 0 foo 2>&1)"
|
|||||||
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
OUTPUT="$(PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar"
|
EXPECTED_OUTPUT='nvm is not compatible with the "PREFIX" environment variable: currently set to "bar"
|
||||||
Run `unset PREFIX` to unset it.'
|
Run `unset PREFIX` to unset it.'
|
||||||
EXIT_CODE="$(PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
EXIT_CODE="$(export PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"
|
[ "_$EXIT_CODE" = "_3" ] || die "'PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 3; got '$EXIT_CODE'"
|
||||||
|
|
||||||
OUTPUT="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo 2>&1)"
|
OUTPUT="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"
|
EXPECTED_OUTPUT='nvm is not compatible with the "NPM_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||||
Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
Run `unset NPM_CONFIG_PREFIX` to unset it.'
|
||||||
EXIT_CODE="$(NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
EXIT_CODE="$(export NPM_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
[ "_$EXIT_CODE" = "_4" ] || die "'NPM_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||||
|
|
||||||
|
OUTPUT="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo 2>&1)"
|
||||||
|
EXPECTED_OUTPUT='nvm is not compatible with the "npm_CONFIG_PREFIX" environment variable: currently set to "bar"
|
||||||
|
Run `unset npm_CONFIG_PREFIX` to unset it.'
|
||||||
|
EXIT_CODE="$(export npm_CONFIG_PREFIX=bar ; nvm_die_on_prefix 0 foo >/dev/null 2>&1; echo $?)"
|
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not error with '$EXPECTED_OUTPUT'; got '$OUTPUT'"
|
||||||
|
[ "_$EXIT_CODE" = "_4" ] || die "'npm_CONFIG_PREFIX=bar nvm_die_on_prefix 0 foo' did not exit with 4; got '$EXIT_CODE'"
|
||||||
|
|
||||||
npm() {
|
npm() {
|
||||||
local args
|
local args
|
||||||
args="$@"
|
args="$@"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ rm -rf "$TEST_DIR"
|
|||||||
mkdir "$TEST_DIR"
|
mkdir "$TEST_DIR"
|
||||||
ln -s "$(command which which)" "$TEST_DIR/which"
|
ln -s "$(command which which)" "$TEST_DIR/which"
|
||||||
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
|
ln -s "$(command which dirname)" "$TEST_DIR/dirname"
|
||||||
|
ln -s "$(command which printf)" "$TEST_DIR/printf"
|
||||||
|
|
||||||
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
|
[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "none" ] || die 'when node not installed, nvm_ls_current did not return "none"'
|
||||||
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
[ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output'
|
||||||
|
|||||||
8
test/install_script/nvm_install_with_node_version
Executable file
8
test/install_script/nvm_install_with_node_version
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
NODE_VERSION=8 \. ../../install.sh
|
||||||
|
|
||||||
|
# nvm installed node 8
|
||||||
|
nvm ls 8 > /dev/null 2>&1 || die "nvm didn't install node 8"
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -ex
|
set -eux
|
||||||
|
|
||||||
die () { echo "$@" ; exit 1; }
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user