Compare commits

..

4 Commits

Author SHA1 Message Date
Jordan Harband
e2e72bab5b
second 2025-02-04 14:03:45 -08:00
Jordan Harband
0560eed9ff nvmrc 2025-02-04 14:03:42 -08:00
Jordan Harband
ad7c98414a libz 2025-02-04 14:03:35 -08:00
Jordan Harband
45ecc7a03e first awk refactor 2025-02-04 14:03:27 -08:00

75
nvm.sh
View File

@ -134,17 +134,15 @@ 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 " ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \
s/--progress-bar /--progress=bar / -e 's/--compressed //' \
s/--compressed // -e 's/--fail //' \
s/--fail // -e 's/-L //' \
s/-L // -e 's/-I /--server-response /' \
s/-I /--server-response / -e 's/-s /-q /' \
s/-s /-q / -e 's/-sS /-nv /' \
s/-sS /-nv / -e 's/-o /-O /' \
s/-o /-O / -e 's/-C - /-c /')
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}\""
@ -1535,20 +1533,33 @@ 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 sed -e " | command awk \
s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#; -v dir_iojs="${NVM_VERSION_DIR_IOJS}" \
s#^${NVM_DIR}/##; -v iojs_prefix="versions/${NVM_IOJS_PREFIX}/" \
\\#^[^v]# d; -v dir="${NVM_DIR}" \
\\#^versions\$# d; -v search="${SEARCH_PATTERN}" \
s#^versions/##; -v node_prefix="${NVM_NODE_PREFIX}" '
s#^v#${NVM_NODE_PREFIX}/v#; {
\\#${SEARCH_PATTERN}# !d; sub(dir_iojs"/", iojs_prefix)
" \ sub("^" dir "/", "")
-e 's#^\([^/]\{1,\}\)/\(.*\)$#\2.\1#;' \ if ($0 ~ /^[^v]/) next
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \ if ($0 == "versions") next
| command sed -e 's#\(.*\)\.\([^\.]\{1,\}\)$#\2-\1#;' \ sub(/^versions\//, "")
-e "s#^${NVM_NODE_PREFIX}-##;" \ sub(/^v/, node_prefix"/v")
)" 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
@ -2040,7 +2051,7 @@ nvm_print_implicit_alias() {
nvm_is_zsh && setopt local_options shwordsplit nvm_is_zsh && setopt local_options shwordsplit
LAST_TWO="$($NVM_COMMAND | command awk '/^v/ { sub(/^v/, ""); split($0, parts, "\\."); short=parts[1]"."parts[2]; if (!seen[short]++) print short }')" LAST_TWO=$($NVM_COMMAND | nvm_grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq)
;; ;;
esac esac
local MINOR local MINOR
@ -2757,19 +2768,13 @@ 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 awk 'NR == 1 { next } /UNMET PEER DEPENDENCY/ { next } { print }')" NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY')
local INSTALLS local INSTALLS
INSTALLS="$(nvm_echo "${NPMLIST}" | command awk ' INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)
/ -> / { next }
/\(empty\)/ { next }
/^npm@/ { next }
{ sub(/^.* (.*@[^ ]*).*/,"\\1"); if (length($0) > 0) print }
' | command xargs
)"
local LINKS local LINKS
LINKS="$(nvm_echo "${NPMLIST}" | command awk '/ -> / { sub(/.* -> /,""); print } ')" LINKS="$(nvm_echo "${NPMLIST}" | command sed -n 's/.* -> \(.*\)/\1/ p')"
nvm_echo "${INSTALLS} //// ${LINKS}" nvm_echo "${INSTALLS} //// ${LINKS}"
} }