mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 09:31:51 +00:00
Compare commits
5 Commits
2fcf3030dc
...
c6d89f01b6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c6d89f01b6 | ||
![]() |
759f70f196 | ||
![]() |
06a9179309 | ||
![]() |
cf9beb7f86 | ||
![]() |
9222739d18 |
53
nvm.sh
53
nvm.sh
@ -136,15 +136,17 @@ nvm_download() {
|
||||
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
||||
elif nvm_has "wget"; then
|
||||
# Emulate curl with wget
|
||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
||||
-e 's/--compressed //' \
|
||||
-e 's/--fail //' \
|
||||
-e 's/-L //' \
|
||||
-e 's/-I /--server-response /' \
|
||||
-e 's/-s /-q /' \
|
||||
-e 's/-sS /-nv /' \
|
||||
-e 's/-o /-O /' \
|
||||
-e 's/-C - /-c /')
|
||||
ARGS=$(nvm_echo "$@" | command sed "
|
||||
s/--progress-bar /--progress=bar /
|
||||
s/--compressed //
|
||||
s/--fail //
|
||||
s/-L //
|
||||
s/-I /--server-response /
|
||||
s/-s /-q /
|
||||
s/-sS /-nv /
|
||||
s/-o /-O /
|
||||
s/-C - /-c /
|
||||
")
|
||||
|
||||
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
||||
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
||||
@ -476,6 +478,12 @@ nvm_tree_contains_path() {
|
||||
previous_pathdir="${node_path}"
|
||||
local pathdir
|
||||
pathdir=$(dirname "${previous_pathdir}")
|
||||
|
||||
# get real directory in case of symbolic links
|
||||
if [ -d "${pathdir-}" ]; then
|
||||
pathdir="$(nvm_cd -P "${pathdir}" && pwd)"
|
||||
fi
|
||||
|
||||
while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] &&
|
||||
[ "${pathdir}" != "${tree}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
|
||||
previous_pathdir="${pathdir}"
|
||||
@ -1413,11 +1421,11 @@ nvm_add_iojs_prefix() {
|
||||
nvm_strip_iojs_prefix() {
|
||||
local NVM_IOJS_PREFIX
|
||||
NVM_IOJS_PREFIX="$(nvm_iojs_prefix)"
|
||||
if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then
|
||||
nvm_echo
|
||||
else
|
||||
nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}"
|
||||
fi
|
||||
|
||||
case "${1-}" in
|
||||
"${NVM_IOJS_PREFIX}") nvm_echo ;;
|
||||
*) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
nvm_ls() {
|
||||
@ -1549,12 +1557,15 @@ nvm_ls() {
|
||||
fi
|
||||
|
||||
if [ "${NVM_ADD_SYSTEM-}" = true ]; then
|
||||
if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then
|
||||
VERSIONS="${VERSIONS}
|
||||
case "${PATTERN}" in
|
||||
'' | v)
|
||||
VERSIONS="${VERSIONS}
|
||||
system"
|
||||
elif [ "${PATTERN}" = 'system' ]; then
|
||||
VERSIONS="system"
|
||||
fi
|
||||
;;
|
||||
system)
|
||||
VERSIONS="system"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -z "${VERSIONS}" ]; then
|
||||
@ -1688,7 +1699,7 @@ EOF
|
||||
LTS="${LTS#lts/}"
|
||||
fi
|
||||
|
||||
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
||||
VERSIONS="$( { command awk -v lts="${LTS-}" '{
|
||||
if (!$1) { next }
|
||||
if (lts && $10 ~ /^\-?$/) { next }
|
||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
||||
@ -2732,7 +2743,7 @@ nvm_npm_global_modules() {
|
||||
local NPMLIST
|
||||
local VERSION
|
||||
VERSION="$1"
|
||||
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY')
|
||||
NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed -e '1d' -e '/UNMET PEER DEPENDENCY/d')
|
||||
|
||||
local INSTALLS
|
||||
INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm tmp3/tmp2
|
||||
rmdir tmp3
|
||||
rm tmp/node
|
||||
rmdir tmp
|
||||
rm tmp2/node
|
||||
@ -14,6 +16,8 @@ mkdir -p tmp
|
||||
touch tmp/node
|
||||
mkdir -p tmp2
|
||||
touch tmp2/node
|
||||
mkdir -p tmp3
|
||||
ln -s tmp2 tmp3/
|
||||
|
||||
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
||||
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
||||
@ -28,4 +32,6 @@ nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
|
||||
|
||||
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
||||
|
||||
nvm_tree_contains_path tmp2 tmp3 && die 'no idea'
|
||||
|
||||
cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user