UNPKG

2.88 kBPlain TextView Raw
1PATH := $(shell pwd)/node_modules/.bin:${PATH}
2
3NPM_PACKAGE := $(shell node -e 'console.log(require("./package.json").name)')
4NPM_VERSION := $(shell node -e 'console.log(require("./package.json").version)')
5
6TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
7
8REMOTE_NAME ?= origin
9REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
10
11CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master)
12GITHUB_PROJ := nodeca/${NPM_PACKAGE}
13
14
15test-all: lint test
16
17lint:
18 if test ! `which jshint` ; then \
19 echo "You need 'jshint' installed in order to run lint." >&2 ; \
20 echo " $ make dev-deps" >&2 ; \
21 exit 128 ; \
22 fi
23 jshint . --show-non-errors
24
25test:
26 @if test ! `which vows` ; then \
27 echo "You need 'vows' installed in order to run tests." >&2 ; \
28 echo " $ make dev-deps" >&2 ; \
29 exit 128 ; \
30 fi
31 NODE_ENV=test vows --spec
32
33doc:
34 @if test ! `which ndoc` ; then \
35 echo "You need 'ndoc' installed in order to generate docs." >&2 ; \
36 echo " $ npm install -g ndoc" >&2 ; \
37 exit 128 ; \
38 fi
39 rm -rf ./doc
40 ndoc --link-format "{package.homepage}/blob/${CURR_HEAD}/{file}#L{line}"
41
42dev-deps:
43 @if test ! `which npm` ; then \
44 echo "You need 'npm' installed." >&2 ; \
45 echo " See: http://npmjs.org/" >&2 ; \
46 exit 128 ; \
47 fi
48 npm install -g jshint
49 npm install
50
51gh-pages:
52 @if test -z ${REMOTE_REPO} ; then \
53 echo 'Remote repo URL not found' >&2 ; \
54 exit 128 ; \
55 fi
56 $(MAKE) doc && \
57 cp -r ./doc ${TMP_PATH} && \
58 touch ${TMP_PATH}/.nojekyll
59 cd ${TMP_PATH} && \
60 git init && \
61 git add . && \
62 git commit -q -m 'Recreated docs'
63 cd ${TMP_PATH} && \
64 git remote add remote ${REMOTE_REPO} && \
65 git push --force remote +master:gh-pages
66 rm -rf ${TMP_PATH}
67
68
69publish:
70 @if test 0 -ne `git status --porcelain | wc -l` ; then \
71 echo "Unclean working tree. Commit or stash changes first." >&2 ; \
72 exit 128 ; \
73 fi
74 @if test 0 -ne `git fetch ; git status | grep '^# Your branch' | wc -l` ; then \
75 echo "Local/Remote history differs. Please push/pull changes." >&2 ; \
76 exit 128 ; \
77 fi
78 @if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
79 echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
80 exit 128 ; \
81 fi
82 git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
83 npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION}
84
85todo:
86 grep 'TODO' -n -r ./lib 2>/dev/null || test true
87
88
89browserify:
90 rm -rf browser && mkdir browser
91 collector --export-name 'BabelFish = window.BabelFish' ./lib/babelfish/runtime \
92 > browser/babelfish-runtime.js
93
94
95lib/babelfish/parser.js:
96 @if test ! `which pegjs` ; then \
97 echo "You need 'pegjs' installed in order to compile parser." >&2 ; \
98 echo " $ make dev-deps" >&2 ; \
99 exit 128 ; \
100 fi
101 pegjs src/parser.pegjs lib/babelfish/parser.js
102
103
104.PHONY: lint test doc dev-deps gh-pages todo
105.SILENT: lint test doc todo