2012-02-02 17:11:45 +00:00
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
#---- Tools
|
|
|
|
|
2013-01-07 19:18:12 +00:00
|
|
|
NODEUNIT := ./node_modules/.bin/nodeunit
|
2012-11-01 19:12:39 +00:00
|
|
|
SUDO := sudo
|
|
|
|
ifeq ($(shell uname -s),SunOS)
|
|
|
|
# On SunOS (e.g. SmartOS) we expect to run the test suite as the
|
|
|
|
# root user -- necessary to run dtrace. Therefore `pfexec` isn't
|
|
|
|
# necessary.
|
|
|
|
SUDO :=
|
|
|
|
endif
|
2013-01-23 00:52:28 +00:00
|
|
|
DTRACE_UP_IN_HERE=
|
|
|
|
ifeq ($(shell uname -s),SunOS)
|
|
|
|
DTRACE_UP_IN_HERE=1
|
|
|
|
endif
|
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
DTRACE_UP_IN_HERE=1
|
|
|
|
endif
|
|
|
|
NODEOPT ?= $(HOME)/opt
|
2012-11-01 19:12:39 +00:00
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
|
|
|
|
|
2012-02-10 08:14:33 +00:00
|
|
|
#---- Files
|
|
|
|
|
2012-08-09 16:10:28 +00:00
|
|
|
JSSTYLE_FILES := $(shell find lib test tools examples -name "*.js") bin/bunyan
|
2012-11-01 06:52:53 +00:00
|
|
|
# All test files *except* dtrace.test.js.
|
2013-01-07 19:18:12 +00:00
|
|
|
NON_DTRACE_TEST_FILES := $(shell ls -1 test/*.test.js | grep -v dtrace | xargs)
|
2012-02-10 08:14:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
#---- Targets
|
|
|
|
|
2012-02-02 17:11:45 +00:00
|
|
|
all:
|
2012-11-01 06:52:53 +00:00
|
|
|
npm install
|
2012-02-02 17:11:45 +00:00
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
# Ensure all version-carrying files have the same version.
|
|
|
|
.PHONY: versioncheck
|
2012-02-02 17:11:45 +00:00
|
|
|
versioncheck:
|
2012-08-13 23:43:32 +00:00
|
|
|
[[ `cat package.json | json version` == `grep '^## ' CHANGES.md | head -1 | awk '{print $$3}'` ]]
|
2013-04-02 00:22:53 +00:00
|
|
|
[[ `cat package.json | json version` == `grep '^var VERSION' bin/bunyan | awk -F"'" '{print $$2}'` ]]
|
2012-06-05 06:22:39 +00:00
|
|
|
[[ `cat package.json | json version` == `grep '^var VERSION' lib/bunyan.js | awk -F"'" '{print $$2}'` ]]
|
2012-02-02 17:11:45 +00:00
|
|
|
@echo Version check ok.
|
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
.PHONY: cutarelease
|
2014-05-31 04:00:09 +00:00
|
|
|
cutarelease: versioncheck check
|
2014-04-03 23:02:28 +00:00
|
|
|
[[ `git status | tail -n1 | cut -c1-17` == "nothing to commit" ]]
|
2012-02-02 23:49:23 +00:00
|
|
|
./tools/cutarelease.py -p bunyan -f package.json -f lib/bunyan.js -f bin/bunyan
|
2012-02-02 17:11:45 +00:00
|
|
|
|
2012-10-25 18:15:12 +00:00
|
|
|
.PHONY: docs
|
|
|
|
docs:
|
|
|
|
@[[ `which ronn` ]] || (echo "No 'ronn' on your PATH. Install with 'gem install ronn'" && exit 2)
|
|
|
|
mkdir -p man/man1
|
|
|
|
ronn --style=toc --manual="bunyan manual" --date=$(shell git log -1 --pretty=format:%cd --date=short) --roff --html docs/bunyan.1.ronn
|
|
|
|
python -c 'import sys; h = open("docs/bunyan.1.html").read(); h = h.replace(".mp dt.flush {float:left;width:8ex}", ""); open("docs/bunyan.1.html", "w").write(h)'
|
|
|
|
python -c 'import sys; h = open("docs/bunyan.1.html").read(); h = h.replace("</body>", """<a href="https://github.com/trentm/node-bunyan"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a></body>"""); open("docs/bunyan.1.html", "w").write(h)'
|
|
|
|
@echo "# test with 'man ./docs/bunyan.1' and 'open ./docs/bunyan.1.html'"
|
|
|
|
|
|
|
|
.PHONY: publish
|
|
|
|
publish:
|
|
|
|
mkdir -p tmp
|
|
|
|
[[ -d tmp/bunyan-gh-pages ]] || git clone git@github.com:trentm/node-bunyan.git tmp/bunyan-gh-pages
|
|
|
|
cd tmp/bunyan-gh-pages && git checkout gh-pages && git pull --rebase origin gh-pages
|
|
|
|
cp docs/index.html tmp/bunyan-gh-pages/index.html
|
|
|
|
cp docs/bunyan.1.html tmp/bunyan-gh-pages/bunyan.1.html
|
|
|
|
(cd tmp/bunyan-gh-pages \
|
|
|
|
&& git commit -a -m "publish latest docs" \
|
|
|
|
&& git push origin gh-pages || true)
|
2012-04-10 22:11:55 +00:00
|
|
|
|
2012-11-01 19:12:39 +00:00
|
|
|
.PHONY: distclean
|
|
|
|
distclean:
|
|
|
|
rm -rf node_modules
|
|
|
|
|
|
|
|
|
2012-04-10 22:11:55 +00:00
|
|
|
#---- test
|
|
|
|
|
2012-02-08 18:05:56 +00:00
|
|
|
.PHONY: test
|
2013-01-07 19:18:12 +00:00
|
|
|
test: $(NODEUNIT)
|
2013-01-23 00:52:28 +00:00
|
|
|
test -z "$(DTRACE_UP_IN_HERE)" || test -n "$(SKIP_DTRACE)" || \
|
|
|
|
(node -e 'require("dtrace-provider").createDTraceProvider("isthisthingon")' && \
|
|
|
|
$(SUDO) $(NODEUNIT) test/dtrace.test.js)
|
2013-01-07 19:18:12 +00:00
|
|
|
$(NODEUNIT) $(NON_DTRACE_TEST_FILES)
|
2012-02-08 18:05:56 +00:00
|
|
|
|
2012-11-01 06:52:53 +00:00
|
|
|
# Test will all node supported versions (presumes install locations I use on
|
|
|
|
# my machine).
|
2014-05-29 06:24:57 +00:00
|
|
|
# Note: 'test10' is last so (if all is well) I end up with a binary
|
|
|
|
# dtrace-provider build for node 0.10 (my current version).
|
2012-04-10 22:11:55 +00:00
|
|
|
.PHONY: testall
|
2014-05-29 06:24:57 +00:00
|
|
|
testall: test08 test10
|
2012-04-10 22:11:55 +00:00
|
|
|
|
2013-03-11 17:48:16 +00:00
|
|
|
.PHONY: test10
|
|
|
|
test10:
|
|
|
|
@echo "# Test node 0.10.x (with node `$(NODEOPT)/node-0.10/bin/node --version`)"
|
|
|
|
@$(NODEOPT)/node-0.10/bin/node --version
|
|
|
|
PATH="$(NODEOPT)/node-0.10/bin:$(PATH)" make distclean all test
|
2012-08-21 18:04:33 +00:00
|
|
|
.PHONY: test08
|
|
|
|
test08:
|
2013-01-23 00:52:28 +00:00
|
|
|
@echo "# Test node 0.8.x (with node `$(NODEOPT)/node-0.8/bin/node --version`)"
|
|
|
|
@$(NODEOPT)/node-0.8/bin/node --version
|
|
|
|
PATH="$(NODEOPT)/node-0.8/bin:$(PATH)" make distclean all test
|
2012-04-10 22:11:55 +00:00
|
|
|
|
2012-08-21 18:04:33 +00:00
|
|
|
|
2012-04-10 22:11:55 +00:00
|
|
|
#---- check
|
|
|
|
|
2012-02-10 08:14:33 +00:00
|
|
|
.PHONY: check-jsstyle
|
|
|
|
check-jsstyle: $(JSSTYLE_FILES)
|
2013-04-02 00:21:01 +00:00
|
|
|
./tools/jsstyle -o indent=4,doxygen,unparenthesized-return=0,blank-after-start-comment=0,leading-right-paren-ok=1 $(JSSTYLE_FILES)
|
2012-02-10 08:14:33 +00:00
|
|
|
|
|
|
|
.PHONY: check
|
|
|
|
check: check-jsstyle
|
|
|
|
@echo "Check ok."
|
|
|
|
|
|
|
|
.PHONY: prepush
|
2012-04-28 00:40:56 +00:00
|
|
|
prepush: check testall
|
2012-02-10 08:14:33 +00:00
|
|
|
@echo "Okay to push."
|