git: e0297e9ec6a2 - main - Mk/Uses/npm.mk: Preserve WRKDIR itself after archiving node modules

From: Hiroki Tagato <tagattie_at_FreeBSD.org>
Date: Tue, 22 Sep 2026 19:53:32 UTC
The branch main has been updated by tagattie:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e0297e9ec6a26fa9e198b78a642611e8b9a28127

commit e0297e9ec6a26fa9e198b78a642611e8b9a28127
Author:     Hiroki Tagato <tagattie@FreeBSD.org>
AuthorDate: 2026-09-22 19:51:07 +0000
Commit:     Hiroki Tagato <tagattie@FreeBSD.org>
CommitDate: 2026-09-22 19:53:22 +0000

    Mk/Uses/npm.mk: Preserve WRKDIR itself after archiving node modules
    
    Removing WRKDIR itself breaks the makesum phase. So only removes the
    contents of WRKDIR (node-modules-cache directory and
    node-modules-cache.mtree file).
---
 Mk/Uses/npm.mk | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/Mk/Uses/npm.mk b/Mk/Uses/npm.mk
index f9d33a383186..1343c00d6120 100644
--- a/Mk/Uses/npm.mk
+++ b/Mk/Uses/npm.mk
@@ -325,9 +325,8 @@ npm-archive-node-modules:
 		${TAR} -cz --options 'gzip:!timestamp' \
 			-f ${DISTDIR}/${DIST_SUBDIR}/${_DISTFILE_prefetch} \
 			-C ${WRKDIR} @node-modules-cache.mtree; \
-		if [ "${TMPDIR}" != "${WRKDIR}" ]; then \
-			${RM} -r ${WRKDIR}; \
-		fi; \
+		${RM} -r ${WRKDIR}/node-modules-cache \
+			${WRKDIR}/node-modules-cache.mtree; \
 	fi
 .    elif ${_NPM_NAME:Myarn*} || ${_NPM_NAME} == pnpm
 .      if ${_NPM_NAME} == pnpm
@@ -441,9 +440,8 @@ npm-archive-node-modules:
 			node-modules-cache.mtree && \
 		${TAR} -cz --options 'gzip:!timestamp' \
 			-f ${DISTDIR}/${DIST_SUBDIR}/${_DISTFILE_prefetch} @node-modules-cache.mtree; \
-		if [ "${TMPDIR}" != "${WRKDIR}" ]; then \
-			${RM} -r ${WRKDIR}; \
-		fi; \
+		${RM} -r ${WRKDIR}/node-modules-cache \
+			${WRKDIR}/node-modules-cache.mtree; \
 	fi
 .    endif
 .  endif