Skip to content

Commit e1faa50

Browse files
committed
nvm.sh: Fall back to "xz on PATH" check
Also refactor, because the fallback check now uses the test Linux had been using.
1 parent c5e1754 commit e1faa50

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

nvm.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,12 +3693,7 @@ nvm_supports_xz() {
36933693

36943694
local NVM_OS
36953695
NVM_OS="$(nvm_get_os)"
3696-
if [ "_${NVM_OS}" = '_linux' ]; then
3697-
if ! command which xz >/dev/null 2>&1; then
3698-
# Linux without xz on the PATH doesn't support extracting xz-compressed tarballs with tar
3699-
return 1
3700-
fi
3701-
elif [ "_${NVM_OS}" = '_darwin' ]; then
3696+
if [ "_${NVM_OS}" = '_darwin' ]; then
37023697
local MACOS_VERSION
37033698
MACOS_VERSION="$(sw_vers -productVersion)"
37043699
if nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
@@ -3711,8 +3706,11 @@ nvm_supports_xz() {
37113706
return 1
37123707
fi
37133708
else
3714-
# Conservatively assume other operating systems don't support extracting xz-compressed tarballs with tar
3715-
return 1
3709+
if ! command which xz >/dev/null 2>&1; then
3710+
# Most OSes without xz on the PATH don't support extracting xz-compressed tarballs with tar
3711+
# (Should correctly handle Linux, SmartOS, maybe more)
3712+
return 1
3713+
fi
37163714
fi
37173715

37183716
# all node versions v4.0.0 and later have xz

0 commit comments

Comments
 (0)