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

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

%:
	dh $@

override_dh_auto_build:
	perl -MJSON -ne 'next unless /^\w/;@ext=();($$type,@ext) = split/\s+/; $$a->{$$type}={source => "iana"}; $$a->{$$type}{extensions}=[@ext] if @ext;}{print to_json($$a)' /etc/mime.types >debian/db.json
	tsc || true
	node dist/scripts/build.js
	find dist/src dist/scripts -name '*.d.ts' -delete
	mv node_modules/@types/mime node_modules/@types/.mime
	tsc
	mv node_modules/@types/.mime node_modules/@types/mime
	dh_auto_build --buildsystem nodejs
	mjs2cjs -o dist/src/index.cjs dist/src/index.js

override_dh_fixperms:
	dh_fixperms
	chmod +x debian/node-mime/usr/share/nodejs/mime/bin/cli.js \
	debian/node-mime/usr/share/nodejs/mime-score/dist/cli.js \
