TESTS =  $(shell ls -S `find test -type f -name "*.test.js" -print`)
REPORTER = spec
MOCHA_OPTS =

install:
	@tnpm install

jshint: install
	@-./node_modules/.bin/jshint ./

test: install
	@NODE_ENV=test ./node_modules/.bin/mocha \
		--reporter $(REPORTER) \
		--require should \
		$(MOCHA_OPTS) \
		$(TESTS)

test-cov cov:install
	@NODE_ENV=test node --harmony \
		node_modules/.bin/istanbul cover --preserve-comments \
		./node_modules/.bin/_mocha \
		-- -u exports \
		--reporter $(REPORTER) \
		--require should \
		$(MOCHA_OPTS) \
		$(TESTS)
	./node_modules/.bin/alicov coverage

test-all: jshint test cov

.PHONY: install test test-all
