#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

WEBPACK=NODE_PATH='/usr/share/nodejs:/usr/lib/nodejs' webpack
CHAI_SRC=$(shell find lib -name "*.js" -type f | LC_ALL=C sort)

%:
	dh $@

override_dh_auto_build:
	cd loupe && sh -e ../debian/nodejs/loupe/build
	esbuild --bundle --format=esm --keep-names --outfile=index.js lib/chai.js
	esbuild --bundle --format=cjs --keep-names --outfile=index.cjs lib/chai.js
	$(WEBPACK)  --config debian/webpack.config.cjs
	(cd dist && terser -o chai.min.js chai.js && rm -f chai.js.LICENSE* || true)
	cd fclone && sh -e ../debian/nodejs/fclone/build

override_dh_auto_install:
	dh_auto_install --buildsystem=nodejs
	rm -rf debian/tmp/usr/share/nodejs/chai/dist

override_dh_installchangelogs:
	dh_installchangelogs -k History.md
