Skip to content

Commit 951b758

Browse files
updated nvm.sh to use darwin-x64 for all binary on mac where node version < 16.0.0
1 parent e4e34ec commit 951b758

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

nvm.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,12 +2360,9 @@ nvm_get_download_slug() {
23602360
fi
23612361
fi
23622362

2363-
# If running MAC M1 :: Node v14.17.0 was the first version to offer official experimental support:
2364-
# https://github.com/nodejs/node/issues/40126 (although binary distributions aren't available until v16)
2365-
if \
2366-
nvm_version_greater '14.17.0' "${VERSION}" \
2367-
|| (nvm_version_greater_than_or_equal_to "${VERSION}" '15.0.0' && nvm_version_greater '16.0.0' "${VERSION}") \
2368-
; then
2363+
# If running MAC M1 :: ARM64 binaries are not available for Node < 16.0.0
2364+
# https://github.com/nodejs/node/issues/40126 (binary distributions aren't available until v16)
2365+
if nvm_version_greater '16.0.0' "${VERSION}"; then
23692366
if [ "_${NVM_OS}" = '_darwin' ] && [ "${NVM_ARCH}" = 'arm64' ]; then
23702367
NVM_ARCH=x64
23712368
fi

test/fast/Unit tests/nvm_get_download_slug

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

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

0 commit comments

Comments
 (0)