[Refactor] combine sed -e invocations/arguments

This commit is contained in:
Jordan Harband 2025-02-04 15:55:10 -08:00
parent 74eb396099
commit 06a9179309
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56

22
nvm.sh
View File

@ -136,15 +136,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}\""
@ -2732,7 +2734,7 @@ 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 sed -e '1d' -e '/UNMET PEER DEPENDENCY/d')
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 sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs)