Fetching contributors…
Cannot retrieve contributors at this time
101 lines (77 sloc) 2.85 KB
NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut -b -6) master)
GITHUB_PROJ := https://github.com/nodeca/${NPM_PACKAGE}
help:
echo "make help - Print this help"
echo "make lint - Lint sources with JSHint"
echo "make test - Lint sources and run all tests"
echo "make browserify - Build browserified version"
echo "make gh-pages - Build and push API docs into gh-pages branch"
echo "make publish - Set new version tag and publish npm package"
echo "make todo - Find and list all TODOs"
lint:
./node_modules/.bin/eslint .
test: lint
@node -e "require('./bower.json')"
@node -e "require('./package.json')"
./node_modules/.bin/mocha -R spec
demo: lint
rm -rf ./demo
mkdir ./demo
cp ./node_modules/codemirror/lib/codemirror.css ./demo/
cp ./support/demo_template/index.html ./demo/
cp ./support/demo_template/demo.css ./demo/
./node_modules/.bin/browserify ./support/demo_template/demo.js -r esprima > ./demo/demo.js
coverage:
rm -rf coverage
./node_modules/.bin/istanbul cover node_modules/.bin/_mocha
gh-pages: demo
@if test -z ${REMOTE_REPO} ; then \
echo 'Remote repo URL not found' >&2 ; \
exit 128 ; \
fi
mkdir ${TMP_PATH}
cp -r demo/* ${TMP_PATH}
touch ${TMP_PATH}/.nojekyll
cd ${TMP_PATH} && \
git init && \
git add . && \
git commit -q -m 'Updated browserified demo'
cd ${TMP_PATH} && \
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_PATH}
publish:
@if test 0 -ne `git status --porcelain | wc -l` ; then \
echo "Unclean working tree. Commit or stash changes first." >&2 ; \
exit 128 ; \
fi
@if test 0 -ne `git fetch ; git status | grep '^# Your branch' | wc -l` ; then \
echo "Local/Remote history differs. Please push/pull changes." >&2 ; \
exit 128 ; \
fi
@if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \
echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \
exit 128 ; \
fi
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
npm publish ${GITHUB_PROJ}/tarball/${NPM_VERSION}
browserify:
rm -rf ./dist
mkdir dist
# Browserify
( echo -n "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" ; \
./node_modules/.bin/browserify -r ./ -s jsyaml \
) > dist/js-yaml.js
# Minify
./node_modules/.bin/uglifyjs dist/js-yaml.js -c -m \
--preamble "/* ${NPM_PACKAGE} ${NPM_VERSION} ${GITHUB_PROJ} */" \
> dist/js-yaml.min.js
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
.PHONY: publish lint test dev-deps gh-pages todo coverage demo
.SILENT: help lint test todo coverage