2017-03-12 07:34:36 +00:00
|
|
|
SHELL=/bin/bash
|
|
|
|
LIB=ssf
|
2017-04-30 04:54:41 +00:00
|
|
|
REQS=
|
|
|
|
ADDONS=
|
|
|
|
AUXTARGETS=
|
2017-03-12 07:34:36 +00:00
|
|
|
CMDS=bin/ssf.njs
|
2017-08-01 02:28:37 +00:00
|
|
|
HTMLLINT=index.html
|
2017-03-12 07:34:36 +00:00
|
|
|
|
|
|
|
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
2017-03-21 07:45:12 +00:00
|
|
|
DEPS=$(sort $(wildcard bits/*.js))
|
2017-03-12 07:34:36 +00:00
|
|
|
TARGET=$(LIB).js
|
2017-03-21 07:45:12 +00:00
|
|
|
FLOWTARGET=$(LIB).flow.js
|
|
|
|
FLOWAUX=$(patsubst %.js,%.flow.js,$(AUXTARGETS))
|
|
|
|
AUXSCPTS=
|
|
|
|
FLOWTGTS=$(TARGET) $(AUXTARGETS) $(AUXSCPTS)
|
|
|
|
UGLIFYOPTS=--support-ie8
|
2017-04-30 04:54:41 +00:00
|
|
|
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
|
2017-03-12 07:34:36 +00:00
|
|
|
|
|
|
|
## Main Targets
|
|
|
|
|
2017-03-21 07:45:12 +00:00
|
|
|
.PHONY: all
|
|
|
|
all: $(TARGET) $(AUXTARGETS) $(AUXSCPTS) ## Build library and auxiliary scripts
|
|
|
|
|
|
|
|
$(FLOWTGTS): %.js : %.flow.js
|
|
|
|
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
|
|
|
|
|
|
|
|
$(FLOWTARGET): $(DEPS)
|
|
|
|
cat $^ | tr -d '\15\32' > $@
|
|
|
|
|
|
|
|
bits/01_version.js: package.json
|
|
|
|
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean: ## Remove targets and build artifacts
|
|
|
|
rm -f $(TARGET) $(FLOWTARGET)
|
2017-03-12 07:34:36 +00:00
|
|
|
|
2020-05-09 05:00:04 +00:00
|
|
|
.PHONY: git
|
|
|
|
git: ## show version string
|
|
|
|
@echo "$$(node -pe 'require("./package.json").version') (ssf)"
|
|
|
|
|
2013-12-14 03:28:57 +00:00
|
|
|
|
2017-03-12 07:34:36 +00:00
|
|
|
## Testing
|
|
|
|
|
|
|
|
.PHONY: test mocha
|
|
|
|
test mocha: ## Run test suite
|
2017-03-21 14:31:33 +00:00
|
|
|
mocha -R spec -t 30000
|
2014-01-20 08:37:48 +00:00
|
|
|
|
2017-04-30 04:54:41 +00:00
|
|
|
.PHONY: test_misc
|
|
|
|
test_misc:
|
2020-05-09 05:00:04 +00:00
|
|
|
MINTEST=1 mocha -R spec -t 30000
|
2014-02-11 19:20:34 +00:00
|
|
|
|
2017-03-21 07:45:12 +00:00
|
|
|
.PHONY: travis
|
|
|
|
travis: ## Run test suite with minimal output
|
|
|
|
mocha -R dot -t 30000
|
|
|
|
|
2017-03-24 05:06:07 +00:00
|
|
|
.PHONY: ctest
|
2017-05-16 19:22:19 +00:00
|
|
|
ctest: ## Build browser test fixtures
|
2020-05-09 05:00:04 +00:00
|
|
|
browserify -t brfs test/{comma,dateNF,dates,exp,fraction,general,implied,oddities,utilities,valid}.js > ctest/test.js
|
2017-04-30 04:54:41 +00:00
|
|
|
|
|
|
|
.PHONY: ctestserv
|
|
|
|
ctestserv: ## Start a test server on port 8000
|
2023-10-24 01:22:11 +00:00
|
|
|
@cd ctest && python -mSimpleHTTPServer || python3 -mhttp.server || npx -y http-server -p 8000 .
|
2017-04-30 04:54:41 +00:00
|
|
|
|
2017-03-24 05:06:07 +00:00
|
|
|
|
2017-03-12 07:34:36 +00:00
|
|
|
## Code Checking
|
|
|
|
|
2018-02-21 03:35:31 +00:00
|
|
|
.PHONY: fullint
|
|
|
|
fullint: lint old-lint tslint flow mdlint ## Run all checks
|
|
|
|
|
2014-01-20 08:37:48 +00:00
|
|
|
.PHONY: lint
|
2017-04-30 04:54:41 +00:00
|
|
|
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
2020-01-26 02:32:32 +00:00
|
|
|
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
|
2017-04-30 04:54:41 +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
|
2017-03-21 07:45:12 +00:00
|
|
|
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
2017-03-12 07:34:36 +00:00
|
|
|
@jshint --show-non-errors $(CMDS)
|
2018-02-21 03:35:31 +00:00
|
|
|
@jshint --show-non-errors package.json test/
|
2017-03-12 07:34:36 +00:00
|
|
|
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
2018-02-21 03:35:31 +00:00
|
|
|
@jscs $(TARGET) $(AUXTARGETS) test/*.js
|
2017-04-30 04:54:41 +00:00
|
|
|
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
2014-01-20 08:37:48 +00:00
|
|
|
|
2018-02-21 03:35:31 +00:00
|
|
|
.PHONY: tslint
|
|
|
|
tslint: $(TARGET) ## Run typescript checks
|
|
|
|
#@npm install dtslint typescript
|
|
|
|
#@npm run-script dtslint
|
|
|
|
dtslint types
|
|
|
|
|
2017-03-12 07:34:36 +00:00
|
|
|
.PHONY: flow
|
|
|
|
flow: lint ## Run flow checker
|
|
|
|
@flow check --all --show-all-errors
|
2014-06-13 15:02:06 +00:00
|
|
|
|
2014-01-20 08:37:48 +00:00
|
|
|
.PHONY: cov
|
2017-06-09 00:59:13 +00:00
|
|
|
cov: misc/coverage.html ## Run coverage test
|
2014-01-20 08:37:48 +00:00
|
|
|
|
2014-02-11 19:20:34 +00:00
|
|
|
.PHONY: cov_min
|
|
|
|
cov_min:
|
|
|
|
MINTEST=1 make cov
|
|
|
|
|
2017-03-21 07:45:12 +00:00
|
|
|
misc/coverage.html: $(TARGET)
|
2017-03-12 07:34:36 +00:00
|
|
|
mocha --require blanket -R html-cov -t 20000 > $@
|
|
|
|
|
|
|
|
.PHONY: full_coveralls
|
2014-03-27 21:31:10 +00:00
|
|
|
full_coveralls:
|
2014-01-20 08:37:48 +00:00
|
|
|
mocha --require blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
|
2014-03-27 21:31:10 +00:00
|
|
|
|
2017-03-12 07:34:36 +00:00
|
|
|
.PHONY: coveralls
|
|
|
|
coveralls: ## Coverage Test + Send to coveralls.io
|
2014-03-27 21:31:10 +00:00
|
|
|
MINTEST=1 make full_coveralls
|
2017-03-12 07:34:36 +00:00
|
|
|
|
2018-02-21 03:35:31 +00:00
|
|
|
MDLINT=README.md
|
|
|
|
.PHONY: mdlint
|
|
|
|
mdlint: $(MDLINT) ## Check markdown documents
|
|
|
|
alex $^
|
|
|
|
mdspell -a -n -x -r --en-us $^
|
2017-03-12 07:34:36 +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 $$!
|