2014-05-01 03:21:53 +00:00
|
|
|
LIB=frac
|
2015-04-22 04:14:03 +00:00
|
|
|
REQS=
|
|
|
|
ADDONS=
|
|
|
|
AUXTARGETS=
|
2017-04-29 17:30:52 +00:00
|
|
|
CMDS=
|
2016-09-23 05:43:23 +00:00
|
|
|
HTMLLINT=index.html
|
2015-04-22 04:14:03 +00:00
|
|
|
|
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
|
|
|
DEPS=$(LIB).md
|
2014-05-01 03:21:53 +00:00
|
|
|
TARGET=$(LIB).js
|
2016-09-23 05:43:23 +00:00
|
|
|
FLOWTARGET=$(LIB).flow.js
|
2017-04-29 17:30:52 +00:00
|
|
|
UGLIFYOPTS=--support-ie8
|
|
|
|
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
|
2016-09-23 05:43:23 +00:00
|
|
|
|
|
|
|
## Main Targets
|
2013-12-14 07:11:37 +00:00
|
|
|
|
2015-04-22 04:14:03 +00:00
|
|
|
.PHONY: all
|
2016-09-23 05:43:23 +00:00
|
|
|
all: $(TARGET) $(AUXTARGETS) ## Build library and auxiliary scripts
|
2015-04-22 04:14:03 +00:00
|
|
|
|
|
|
|
$(TARGET) $(AUXTARGETS): %.js : %.flow.js
|
2016-09-23 05:43:23 +00:00
|
|
|
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
|
2015-04-22 04:14:03 +00:00
|
|
|
|
2016-09-23 05:43:23 +00:00
|
|
|
$(FLOWTARGET): $(DEPS)
|
2024-04-23 20:12:51 +00:00
|
|
|
voc $^ || npx voc $^
|
2015-04-22 04:14:03 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
2016-09-23 05:43:23 +00:00
|
|
|
clean: ## Remove targets and build artifacts
|
|
|
|
rm -f $(TARGET) $(FLOWTARGET)
|
2015-04-22 04:14:03 +00:00
|
|
|
|
2016-09-23 05:43:23 +00:00
|
|
|
## JavaScript
|
2015-04-22 04:14:03 +00:00
|
|
|
|
|
|
|
.PHONY: test mocha
|
2016-09-23 05:43:23 +00:00
|
|
|
test mocha: test.js $(TARGET) ## Run JS test suite
|
2015-04-22 04:14:03 +00:00
|
|
|
mocha -R spec -t 20000
|
2014-05-01 02:32:25 +00:00
|
|
|
|
2017-03-29 07:08:09 +00:00
|
|
|
.PHONY: ctest
|
|
|
|
ctest: ## Build browser test (into ctest/ subdirectory)
|
|
|
|
browserify -t brfs test.js > ctest/test.js
|
|
|
|
cp -f $(TARGET) ctest/
|
|
|
|
|
|
|
|
.PHONY: ctestserv
|
|
|
|
ctestserv: ## Start a test server on port 8000
|
2024-04-23 20:12:51 +00:00
|
|
|
@cd ctest && python -mSimpleHTTPServer || python3 -mhttp.server || npx -y http-server -p 8000 .
|
2017-03-29 07:08:09 +00:00
|
|
|
|
2018-01-19 05:03:42 +00:00
|
|
|
.PHONY: fullint
|
|
|
|
fullint: lint old-lint tslint flow mdlint ## Run all checks
|
|
|
|
|
2014-05-01 02:32:25 +00:00
|
|
|
.PHONY: lint
|
2017-04-29 17:30:52 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
2020-05-13 21:16:25 +00:00
|
|
|
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
|
2017-04-29 17:30:52 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
|
|
|
|
|
|
|
.PHONY: old-lint
|
|
|
|
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
2016-09-23 05:43:23 +00:00
|
|
|
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
2017-04-29 17:30:52 +00:00
|
|
|
@jshint --show-non-errors $(CMDS)
|
2016-09-23 05:43:23 +00:00
|
|
|
@jshint --show-non-errors package.json
|
|
|
|
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
|
|
|
@jscs $(TARGET) $(AUXTARGETS)
|
2017-04-29 17:30:52 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
2015-04-22 04:14:03 +00:00
|
|
|
|
2018-01-19 05:03:42 +00:00
|
|
|
.PHONY: tslint
|
|
|
|
tslint: $(TARGET) ## Run typescript checks
|
|
|
|
#@npm install dtslint typescript
|
|
|
|
#@npm run-script dtslint
|
|
|
|
dtslint types
|
|
|
|
|
2015-04-22 04:14:03 +00:00
|
|
|
.PHONY: flow
|
2016-09-23 05:43:23 +00:00
|
|
|
flow: lint ## Run flow checker
|
|
|
|
@flow check --all --show-all-errors
|
2014-05-01 02:32:25 +00:00
|
|
|
|
2016-09-23 05:43:23 +00:00
|
|
|
.PHONY: cov
|
|
|
|
cov: misc/coverage.html ## Run coverage test
|
2014-05-01 02:32:25 +00:00
|
|
|
|
2015-04-22 04:14:03 +00:00
|
|
|
misc/coverage.html: $(TARGET) test.js
|
|
|
|
mocha --require blanket -R html-cov -t 20000 > $@
|
2014-05-01 02:32:25 +00:00
|
|
|
|
2016-09-23 05:43:23 +00:00
|
|
|
.PHONY: coveralls
|
|
|
|
coveralls: ## Coverage Test + Send to coveralls.io
|
|
|
|
mocha --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
|
2014-05-01 03:21:53 +00:00
|
|
|
|
2018-01-19 05:03:42 +00:00
|
|
|
MDLINT=README.md frac.md
|
|
|
|
.PHONY: mdlint
|
|
|
|
mdlint: $(MDLINT) ## Check markdown documents
|
|
|
|
alex $^
|
|
|
|
mdspell -a -n -x -r --en-us $^
|
|
|
|
|
2014-05-01 03:21:53 +00:00
|
|
|
.PHONY: dist
|
2016-09-23 05:43:23 +00:00
|
|
|
dist: dist-deps $(TARGET) ## Prepare JS files for distribution
|
2014-05-01 03:21:53 +00:00
|
|
|
cp $(TARGET) dist/
|
|
|
|
cp LICENSE dist/
|
2017-04-29 17:30:52 +00:00
|
|
|
uglifyjs $(UGLIFYOPTS) $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 frac.js)"
|
2015-04-22 04:14:03 +00:00
|
|
|
misc/strip_sourcemap.sh dist/$(LIB).min.js
|
|
|
|
|
|
|
|
.PHONY: aux
|
|
|
|
aux: $(AUXTARGETS)
|
|
|
|
.PHONY: dist-deps
|
|
|
|
dist-deps:
|
|
|
|
|
|
|
|
## Python
|
|
|
|
|
|
|
|
.PHONY: pylint
|
2016-09-23 05:43:23 +00:00
|
|
|
pylint: frac.py $(wildcard test_*.py) ## Run pep8 check
|
2015-04-22 04:14:03 +00:00
|
|
|
pep8 $^
|
|
|
|
|
|
|
|
.PHONY: pypi
|
2016-09-23 05:43:23 +00:00
|
|
|
pydist: frac.py ## Upload Python module to PyPI
|
2015-04-22 04:14:03 +00:00
|
|
|
python setup.py sdist upload
|
|
|
|
|
2015-05-05 06:19:23 +00:00
|
|
|
.PHONY: pytest pypytest
|
2016-09-23 05:43:23 +00:00
|
|
|
pytest: pylint ## Run Python test suite
|
2015-05-05 06:19:23 +00:00
|
|
|
py.test -v --durations=5
|
|
|
|
|
2016-09-23 05:43:23 +00:00
|
|
|
pypytest: pylint ## Run Python test suite in pypy
|
2015-05-05 06:19:23 +00:00
|
|
|
pypy $$(which py.test) -v --durations=5
|
2016-09-23 05:43:23 +00:00
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
|
|
|
|
|
|
|
|
#* To show a spinner, append "-spin" to any target e.g. cov-spin
|
|
|
|
%-spin:
|
|
|
|
@make $* & bash misc/spin.sh $$!
|