commit e6de31d2d622f01aae6d465cf332a268332942f4
parent ec62ec39d82b6b42ee2ec9ad866a79c56b8e2990
Author: Martin von Gagern <Martin.vGagern@gmx.net>
Date: Wed, 24 Aug 2016 03:05:50 +0200
Call “npm install” automatically if package.json changed (#505)
This adds a stamp file which is used to detect whether the `package.json`
file got updated since the last `npm install`. If so, `npm install` is run
again to update all modules to the version described in `package.json`.
This happens as a dependency of only those modules which actually need some
npm-installed module.
Setting the corresponding make variable to the empty string disables the
feature, which is used by the `make` invocation in the `prepublish` script
inside `package.json` to avoid infinite loops. It can also be used by
developers working in an environment with reduced connectivity, as long as
they know what they are doing.
Diffstat:
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
@@ -13,19 +13,24 @@ export UGLIFYJS = $(realpath ./node_modules/.bin/uglifyjs) \
--beautify \
ascii_only=true,beautify=false
-setup:
+# The prepublish script in package.json will override the following variable,
+# setting it to the empty string and thereby avoiding an infinite recursion
+NIS = .npm-install.stamp
+
+$(NIS) setup: package.json
npm install
+ @touch $(NIS)
-lint: katex.js server.js cli.js $(wildcard src/*.js) $(wildcard test/*.js) $(wildcard contrib/*/*.js) $(wildcard dockers/*/*.js)
- ./node_modules/.bin/eslint $^
+lint: $(NIS) katex.js server.js cli.js $(wildcard src/*.js) $(wildcard test/*.js) $(wildcard contrib/*/*.js) $(wildcard dockers/*/*.js)
+ ./node_modules/.bin/eslint $(filter-out *.stamp,$^)
-build/katex.js: katex.js $(wildcard src/*.js)
+build/katex.js: katex.js $(wildcard src/*.js) $(NIS)
$(BROWSERIFY) $< --standalone katex > $@
build/katex.min.js: build/katex.js
$(UGLIFYJS) < $< > $@
-build/katex.less.css: static/katex.less $(wildcard static/*.less)
+build/katex.less.css: static/katex.less $(wildcard static/*.less) $(NIS)
./node_modules/.bin/lessc $< $@
build/katex.min.css: build/katex.less.css
@@ -78,10 +83,10 @@ compress: build/katex.min.js build/katex.min.css
@printf "Minified, gzipped css: %6d\n" "${CSSSIZE}"
@printf "Total: %6d\n" "${TOTAL}"
-serve:
+serve: $(NIS)
node server.js
-test:
+test: $(NIS)
JASMINE_CONFIG_PATH=test/jasmine.json node_modules/.bin/jasmine
PERL=perl
@@ -94,7 +99,7 @@ extended_metrics:
cd metrics && $(PERL) ./mapping.pl | $(PYTHON) ./extract_tfms.py | $(PYTHON) ./extract_ttfs.py | $(PYTHON) ./format_json.py --width > ../src/fontMetricsData.js
clean:
- rm -rf build/*
+ rm -rf build/* $(NIS)
-screenshots: test/screenshotter/unicode-fonts
+screenshots: test/screenshotter/unicode-fonts $(NIS)
dockers/Screenshotter/screenshotter.sh
diff --git a/package.json b/package.json
@@ -33,7 +33,7 @@
"bin": "cli.js",
"scripts": {
"test": "make lint test",
- "prepublish": "make dist"
+ "prepublish": "make NIS= dist"
},
"dependencies": {
"match-at": "^0.1.0"