Просмотр исходного кода

ci: reinstall frontend dependencies if npm changed node_modules

npm rewrites node_modules/.package-lock.json when it changes the installed
tree, for example after npm install --no-save, so relying on that file
alone would keep a tree that no longer matches the lockfile. Record clean
installs in a separate stamp that is invalidated when npm changes the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 21 часов назад
Родитель
Сommit
ef765b40cb
1 измененных файлов с 6 добавлено и 4 удалено
  1. 6 4
      frontend/Makefile

+ 6 - 4
frontend/Makefile

@@ -14,12 +14,14 @@ unittests: deps
 clean:
 	$(call delete-files,dist)
 
-# npm ci writes node_modules/.package-lock.json, so it only needs to run again
-# when package.json or the lockfile is newer than the last install.
-deps: node_modules/.package-lock.json
+# Only run npm ci again when package.json or the lockfile is newer than the
+# last clean install, or when npm has changed node_modules since (for example
+# npm install), which rewrites node_modules/.package-lock.json.
+deps: node_modules/.npm-ci-stamp
 
-node_modules/.package-lock.json: package.json package-lock.json
+node_modules/.npm-ci-stamp: package.json package-lock.json $(wildcard node_modules/.package-lock.json)
 	npm ci
+	touch $@
 
 build:
 	npm run build