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

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

%:
	dh $@

# tshy is not usable here: it depends on node-minimatch (<< 11), which does
# not work with brace-expansion 5.  Build the ESM and CommonJS trees directly.
override_dh_auto_build:
	tsc -p .tshy/esm.json --outDir dist/esm
	tsc -p .tshy/commonjs.json --module commonjs --moduleResolution node10 --ignoreDeprecations 6.0 --outDir dist/commonjs
	echo '{"type":"commonjs"}' > dist/commonjs/package.json
	cp debian/index.cjs .
	node -e 'var f="package.json",p=JSON.parse(require("fs").readFileSync(f));p.main="./index.cjs";p.exports["."].require.default="./index.cjs";p.files.push("index.cjs");require("fs").writeFileSync(f,JSON.stringify(p,null,2)+"\n")'

override_dh_auto_clean:
	dh_auto_clean
	rm -rf .tshy-build dist

override_dh_auto_test:
	MINIMATCH_MODULE=. sh debian/tests/pkg-js/test
