1 | NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
|
2 | NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
|
3 |
|
4 | TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
|
5 |
|
6 | REMOTE_NAME ?= origin
|
7 | REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
|
8 |
|
9 | CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master)
|
10 | GITHUB_PROJ := https://github.com//markdown-it/${NPM_PACKAGE}
|
11 |
|
12 | TEST_CASES := $(patsubst src/test/%.md,test/fixtures/%.txt,$(wildcard src/test/*.md))
|
13 |
|
14 | index.js: src/index.js
|
15 | sed -re 's/^(\ *)\1/\1/g' $< > $@
|
16 |
|
17 | test/fixtures/%.txt: src/test/%.md
|
18 | sed -re 's/^##\ ?(.+)$$/\1:/g' \
|
19 | -re 's/^>\ //g' \
|
20 | -re 's/^```markdown$$/\n./g'\
|
21 | -re '/```html/d' \
|
22 | -re 's/^```$$/./g' $< > $@
|
23 |
|
24 | build: index.js ${TEST_CASES}
|
25 |
|
26 | lint: build
|
27 | ./node_modules/.bin/eslint .
|
28 |
|
29 | test: lint
|
30 | ./node_modules/.bin/mocha -R spec
|
31 |
|
32 | coverage:
|
33 | rm -rf coverage
|
34 | ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha
|
35 |
|
36 | test-ci: lint
|
37 | istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage
|
38 |
|
39 | browserify:
|
40 | rm -rf ./dist
|
41 | mkdir dist
|
42 | # Browserify
|
43 | ( printf "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" ; \
|
44 | ./node_modules/.bin/browserify ./ -s markdownitDeflist \
|
45 | ) > dist/markdown-it-multimd-table.js
|
46 | # Minify
|
47 | ./node_modules/.bin/uglifyjs dist/markdown-it-multimd-table.js -b beautify=false,ascii-only=true -c -m \
|
48 | --preamble "/*! ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} @license MIT */" \
|
49 | > dist/markdown-it-multimd-table.min.js
|
50 |
|
51 | .PHONY: lint test coverage build
|
52 | .SILENT: lint test
|