UNPKG

1.73 kBPlain TextView Raw
1NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
2NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
3
4TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
5
6REMOTE_NAME ?= origin
7REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
8
9CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master)
10GITHUB_PROJ := https://github.com//markdown-it/${NPM_PACKAGE}
11
12TEST_CASES := $(patsubst src/test/%.md,test/fixtures/%.txt,$(wildcard src/test/*.md))
13
14index.js: src/index.js
15 sed -re 's/^(\ *)\1/\1/g' $< > $@
16
17test/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
24build: index.js ${TEST_CASES}
25
26lint: build
27 ./node_modules/.bin/eslint .
28
29test: lint
30 ./node_modules/.bin/mocha -R spec
31
32coverage:
33 rm -rf coverage
34 ./node_modules/.bin/istanbul cover node_modules/.bin/_mocha
35
36test-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
39browserify:
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