git: 8ffb09feda36 - 2026Q3 - Mk/Uses/npm.mk: Correct NPM version comparison
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 10 Sep 2026 20:54:47 UTC
The branch 2026Q3 has been updated by tagattie:
URL: https://cgit.FreeBSD.org/ports/commit/?id=8ffb09feda3670ba4a5da0b5b5e05b45da8ef9ba
commit 8ffb09feda3670ba4a5da0b5b5e05b45da8ef9ba
Author: Hiroki Tagato <tagattie@FreeBSD.org>
AuthorDate: 2026-07-14 07:44:52 +0000
Commit: Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2026-09-10 20:54:25 +0000
Mk/Uses/npm.mk: Correct NPM version comparison
Assuming NPM version follows the semantic versioning, NPM_VER:R was
used to obtain the major and the minor version of NPM. However, when
the minor version is equal or greater than 10, the comparison
NPM:R >= 11.3 does not make sense. This change corrects version
comparison using major and minor combination.
(cherry picked from commit dad28f35db5afc535469fdffc9b6042e5dc25871)
---
Mk/Uses/npm.mk | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/Mk/Uses/npm.mk b/Mk/Uses/npm.mk
index 730d9c2d3ca8..b6896d72b69c 100644
--- a/Mk/Uses/npm.mk
+++ b/Mk/Uses/npm.mk
@@ -157,6 +157,10 @@ NPM_VER!= ${CAT} ${PKGJSONSDIR}/${NPM_PKGFILE} | \
${CUT} -f 2 -d '@'
. if empty(NPM_VER)
IGNORE= does not specity version of ${NPM_CMDNAME} used for prefetching node modules
+. else
+_NPM_VER_PARTS= ${NPM_VER:S/./ /g}
+NPM_VER_MAJOR= ${_NPM_VER_PARTS:[1]}
+NPM_VER_MINOR= ${_NPM_VER_PARTS:[2]}
. endif
. endif
@@ -261,7 +265,7 @@ DISTFILES+= ${_DISTFILE_prefetch}:prefetch
FETCH_DEPENDS+= ${_NPM_PKGNAME}>0:${_NPM_PORTDIR}
. elif ${_NPM_NAME} == pnpm
FETCH_DEPENDS+= jq:textproc/jq
-. if ${NPM_VER:R:R} >= 11
+. if ${NPM_VER_MAJOR} >= 11
FETCH_DEPENDS+= sqlite3:databases/sqlite3
. endif
. endif
@@ -300,7 +304,7 @@ npm-archive-node-modules:
fi
. elif ${_NPM_NAME:Myarn*} || ${_NPM_NAME} == pnpm
. if ${_NPM_NAME} == pnpm
-. if ${NPM_VER:R:R} >= 11
+. if ${NPM_VER_MAJOR} >= 11
@if [ ! -f ${DISTDIR}/${DIST_SUBDIR}/${_DISTFILE_prefetch} ] && [ -d ${WRKDIR}/node-modules-cache ]; then \
${ECHO_MSG} "===> Normalizing timestamps and permissions of prefetched node modules"; \
tmpdir=${WRKDIR}/pnpm_tmp; \
@@ -425,9 +429,10 @@ _USES_extract+= 600:npm-extract-node-package-manager \
EXTRACT_DEPENDS+= ${_NPM_PKGNAME}>0:${_NPM_PORTDIR}
. elif ${_NPM_NAME} == yarn2 || ${_NPM_NAME} == yarn4 || ${_NPM_NAME} == pnpm
EXTRACT_DEPENDS+= ${_NODEJS_PKGNAME}>0:${_NODEJS_PORT}
-. if ${_NPM_NAME} == pnpm && ${NPM_VER:R:R} >= 11
+. if ${_NPM_NAME} == pnpm && ${NPM_VER_MAJOR} >= 11
EXTRACT_DEPENDS+= sqlite3:databases/sqlite3
-. if ${NPM_VER:R} >= 11.3
+. if (${NPM_VER_MAJOR} == 11 && ${NPM_VER_MINOR} >= 3) || \
+ ${NPM_VER_MAJOR} >= 12
NPM_EXTRACT_FLAGS+= --trust-lockfile
. endif
. endif
@@ -486,7 +491,7 @@ npm-install-node-modules:
fi
. elif ${_NPM_NAME} == pnpm
@${ECHO_MSG} "===> Installing node modules from prefetched cache"
-. if ${NPM_VER:R:R} >= 11
+. if ${NPM_VER_MAJOR} >= 11
@if [ -d ${EXTRACT_WRKDIR}/${NPM_MODULE_CACHE} ]; then \
normalized_db_dump=${EXTRACT_WRKDIR}/${NPM_MODULE_CACHE}/v11/index_dump.sql; \
index_db=${EXTRACT_WRKDIR}/${NPM_MODULE_CACHE}/v11/index.db; \