Skip to content

Commit 3385907

Browse files
Rahulbeniwal26119ljharb
authored andcommitted
updated nvm.sh to use darwin-x64 for all binary on mac where node version < 16.0.0
1 parent 5533699 commit 3385907

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

nvm.sh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,15 +2405,10 @@ nvm_get_download_slug() {
24052405
fi
24062406
fi
24072407

2408-
# If running MAC M1 :: Node v14.17.0 was the first version to offer official experimental support:
2409-
# https://github.com/nodejs/node/issues/40126 (although binary distributions aren't available until v16)
2410-
if \
2411-
nvm_version_greater '14.17.0' "${VERSION}" \
2412-
|| (nvm_version_greater_than_or_equal_to "${VERSION}" '15.0.0' && nvm_version_greater '16.0.0' "${VERSION}") \
2413-
; then
2414-
if [ "_${NVM_OS}" = '_darwin' ] && [ "${NVM_ARCH}" = 'arm64' ]; then
2415-
NVM_ARCH=x64
2416-
fi
2408+
# If running MAC M1 :: ARM64 binaries are not available for Node < 16.0.0
2409+
# https://github.com/nodejs/node/issues/40126 (binary distributions aren't available until v16)
2410+
if nvm_version_greater '16.0.0' "${VERSION}" && [ "_${NVM_OS}" = '_darwin' ] && [ "${NVM_ARCH}" = 'arm64' ]; then
2411+
NVM_ARCH=x64
24172412
fi
24182413

24192414
if [ "${KIND}" = 'binary' ]; then

test/fast/Unit tests/nvm_get_download_slug

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,26 @@ ACTUAL="$(nvm_get_download_slug iojs source 15.99.99)"
110110
EXPECTED="iojs-15.99.99"
111111
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
112112

113+
114+
REAL_OS="$(command uname -s 2>/dev/null || echo '')"
115+
REAL_ARCH="$(command uname -m 2>/dev/null || echo '')"
116+
if [ "${REAL_OS}" = "Darwin" ] && [ "${REAL_ARCH}" = "arm64" ]; then
117+
# Node < 16 uses x64 on darwin-arm64
118+
ACTUAL="$(nvm_get_download_slug node binary 14.21.3)"
119+
EXPECTED='node-14.21.3-darwin-x64'
120+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
121+
ACTUAL="$(nvm_get_download_slug node binary 15.99.99)"
122+
EXPECTED='node-15.99.99-darwin-x64'
123+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
124+
ACTUAL="$(nvm_get_download_slug iojs binary 15.99.99)"
125+
EXPECTED='iojs-15.99.99-darwin-x64'
126+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
127+
128+
# Test Node >= 16 uses arm64 on darwin-arm64
129+
ACTUAL="$(nvm_get_download_slug node binary 16.0.0)"
130+
EXPECTED='node-16.0.0-darwin-arm64'
131+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
132+
ACTUAL="$(nvm_get_download_slug node binary 18.0.0)"
133+
EXPECTED='node-18.0.0-darwin-arm64'
134+
[ "${ACTUAL}" = "${EXPECTED}" ] || die "expected >${EXPECTED}<, got >${ACTUAL}<"
135+
fi

0 commit comments

Comments
 (0)