JS ?= node

.PHONY: test
test:
	# To get the latest generated *.ts files
	dune build
	# Install TypeScript and JavaScript dependencies locally
	npm install
	$(MAKE) lint
	# Compile TypeScript (handwritten + generated by atdts) to JavaScript
	npm run tsc
	# Run the resulting code (compiled from TypeScript)
	#
	# The empty comments are used to force Make to call the shell without
	# which it tries to execute the command directly and fails in some
	# setups (nvm, Node v24.1.0, Ubuntu 24.04, GNU Make 4.3)
	# with "Permission denied" for an unknown reason.
	$(JS) manual_sample.js   #
	$(JS) test_atdts.js      #

# Check for warnings from tslint and eslint, especially in the generated code
.PHONY: lint
lint:
	npm run lint

.PHONY: clean
clean:
	dune clean
	git clean -dfX
