mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-17 11:03:44 +00:00
Compare commits
2 Commits
e2e72bab5b
...
8283b91ede
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8283b91ede | ||
![]() |
d5e3896466 |
75
nvm.sh
75
nvm.sh
@ -134,15 +134,17 @@ nvm_download() {
|
|||||||
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}"
|
||||||
elif nvm_has "wget"; then
|
elif nvm_has "wget"; then
|
||||||
# Emulate curl with wget
|
# Emulate curl with wget
|
||||||
ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
|
ARGS=$(nvm_echo "$@" | command sed "
|
||||||
-e 's/--compressed //' \
|
s/--progress-bar /--progress=bar /
|
||||||
-e 's/--fail //' \
|
s/--compressed //
|
||||||
-e 's/-L //' \
|
s/--fail //
|
||||||
-e 's/-I /--server-response /' \
|
s/-L //
|
||||||
-e 's/-s /-q /' \
|
s/-I /--server-response /
|
||||||
-e 's/-sS /-nv /' \
|
s/-s /-q /
|
||||||
-e 's/-o /-O /' \
|
s/-sS /-nv /
|
||||||
-e 's/-C - /-c /')
|
s/-o /-O /
|
||||||
|
s/-C - /-c /
|
||||||
|
")
|
||||||
|
|
||||||
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
if [ -n "${NVM_AUTH_HEADER:-}" ]; then
|
||||||
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\""
|
||||||
@ -1533,33 +1535,20 @@ nvm_ls() {
|
|||||||
fi
|
fi
|
||||||
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
|
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
|
||||||
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
|
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
|
||||||
| command awk \
|
| command sed -e "
|
||||||
-v dir_iojs="${NVM_VERSION_DIR_IOJS}" \
|
s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#;
|
||||||
-v iojs_prefix="versions/${NVM_IOJS_PREFIX}/" \
|
s#^${NVM_DIR}/##;
|
||||||
-v dir="${NVM_DIR}" \
|
\\#^[^v]# d;
|
||||||
-v search="${SEARCH_PATTERN}" \
|
\\#^versions\$# d;
|
||||||
-v node_prefix="${NVM_NODE_PREFIX}" '
|
s#^versions/##;
|
||||||
{
|
s#^v#${NVM_NODE_PREFIX}/v#;
|
||||||
sub(dir_iojs"/", iojs_prefix)
|
\\#${SEARCH_PATTERN}# !d;
|
||||||
sub("^" dir "/", "")
|
" \
|
||||||
if ($0 ~ /^[^v]/) next
|
-e 's#^\([^/]\{1,\}\)/\(.*\)$#\2.\1#;' \
|
||||||
if ($0 == "versions") next
|
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \
|
||||||
sub(/^versions\//, "")
|
| command sed -e 's#\(.*\)\.\([^\.]\{1,\}\)$#\2-\1#;' \
|
||||||
sub(/^v/, node_prefix"/v")
|
-e "s#^${NVM_NODE_PREFIX}-##;" \
|
||||||
if ($0 !~ search) next
|
)"
|
||||||
sub(/^([^/]+)\/(.*)$/, "\\2.\\1")
|
|
||||||
print
|
|
||||||
}
|
|
||||||
' \
|
|
||||||
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \
|
|
||||||
| command awk -v node_prefix="${NVM_NODE_PREFIX}" '
|
|
||||||
{
|
|
||||||
sub(/^(.*)\.([^.]*)$/, "\\2-\\1")
|
|
||||||
sub("^" node_prefix"-", "")
|
|
||||||
print
|
|
||||||
}
|
|
||||||
'
|
|
||||||
)"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2051,7 +2040,7 @@ nvm_print_implicit_alias() {
|
|||||||
|
|
||||||
nvm_is_zsh && setopt local_options shwordsplit
|
nvm_is_zsh && setopt local_options shwordsplit
|
||||||
|
|
||||||
LAST_TWO=$($NVM_COMMAND | nvm_grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq)
|
LAST_TWO="$($NVM_COMMAND | command awk '/^v/ { sub(/^v/, ""); split($0, parts, "\\."); short=parts[1]"."parts[2]; if (!seen[short]++) print short }')"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
local MINOR
|
local MINOR
|
||||||
@ -2768,13 +2757,19 @@ nvm_npm_global_modules() {
|
|||||||
local NPMLIST
|
local NPMLIST
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
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 awk 'NR == 1 { next } /UNMET PEER DEPENDENCY/ { next } { print }')"
|
||||||
|
|
||||||
local INSTALLS
|
local INSTALLS
|
||||||
INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
|
INSTALLS="$(nvm_echo "${NPMLIST}" | command awk '
|
||||||
|
/ -> / { next }
|
||||||
|
/\(empty\)/ { next }
|
||||||
|
/^npm@/ { next }
|
||||||
|
{ sub(/^.* (.*@[^ ]*).*/,"\\1"); if (length($0) > 0) print }
|
||||||
|
' | command xargs
|
||||||
|
)"
|
||||||
|
|
||||||
local LINKS
|
local LINKS
|
||||||
LINKS="$(nvm_echo "${NPMLIST}" | command sed -n 's/.* -> \(.*\)/\1/ p')"
|
LINKS="$(nvm_echo "${NPMLIST}" | command awk '/ -> / { sub(/.* -> /,""); print } ')"
|
||||||
|
|
||||||
nvm_echo "${INSTALLS} //// ${LINKS}"
|
nvm_echo "${INSTALLS} //// ${LINKS}"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user