Fix webpack result test in dist/

When building in production mode, there is no index.js, just an
index.min.js.gz. This previously caused unnecessary rebuilds, or even
RPM build failures in environments where npm was not available. Test for
index.html instead, which is reliable.

Also factor this out into a constant to make it easier to adjust in
forked projects.
This commit is contained in:
Martin Pitt 2018-07-17 23:00:36 +02:00 committed by Lars Karlitski
parent d3b8811ac6
commit 70c7242d9d

View file

@ -7,8 +7,10 @@ export TEST_OS
VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS) VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS)
# one example directory from `npm install` to check if that already ran # one example directory from `npm install` to check if that already ran
NODE_MODULES_TEST=node_modules/po2json NODE_MODULES_TEST=node_modules/po2json
# one example file in dist/ from webpack to check if that already ran
WEBPACK_TEST=dist/index.html
all: dist/index.js all: $(WEBPACK_TEST)
# #
# i18n # i18n
@ -60,21 +62,21 @@ dist/po.%.js: po/%.po $(NODE_MODULES_TEST)
%.spec: %.spec.in %.spec: %.spec.in
sed -e 's/@VERSION@/$(VERSION)/g' $< > $@ sed -e 's/@VERSION@/$(VERSION)/g' $< > $@
dist/index.js: $(NODE_MODULES_TEST) $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS)) $(WEBPACK_TEST): $(NODE_MODULES_TEST) $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS))
NODE_ENV=$(NODE_ENV) npm run build NODE_ENV=$(NODE_ENV) npm run build
clean: clean:
rm -rf dist/ rm -rf dist/
[ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec [ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec
install: dist/index.js install: $(WEBPACK_TEST)
mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)
mkdir -p $(DESTDIR)/usr/share/metainfo/ mkdir -p $(DESTDIR)/usr/share/metainfo/
cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/ cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/
# this requires a built source tree and avoids having to install anything system-wide # this requires a built source tree and avoids having to install anything system-wide
devel-install: dist/index.js devel-install: $(WEBPACK_TEST)
mkdir -p ~/.local/share/cockpit mkdir -p ~/.local/share/cockpit
ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME) ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME)