root / HServer / 00.Server / 00.Program / node_modules / bunyan / Makefile
이력 | 보기 | 이력해설 | 다운로드 (5.54 KB)
1 | |
---|---|
2 |
#---- Tools |
3 | |
4 |
NODEUNIT := ./node_modules/.bin/nodeunit |
5 |
SUDO := sudo |
6 |
ifeq ($(shell uname -s),SunOS) |
7 |
# On SunOS (e.g. SmartOS) we expect to run the test suite as the |
8 |
# root user -- necessary to run dtrace. Therefore `pfexec` isn't |
9 |
# necessary. |
10 |
SUDO := |
11 |
endif |
12 |
DTRACE_UP_IN_HERE= |
13 |
ifeq ($(shell uname -s),SunOS) |
14 |
DTRACE_UP_IN_HERE=1 |
15 |
endif |
16 |
ifeq ($(shell uname -s),Darwin) |
17 |
DTRACE_UP_IN_HERE=1 |
18 |
endif |
19 |
NODEOPT ?= $(HOME)/opt |
20 | |
21 | |
22 |
#---- Files |
23 | |
24 |
JSSTYLE_FILES := $(shell find lib test tools examples -name "*.js") bin/bunyan |
25 |
# All test files *except* dtrace.test.js. |
26 |
NON_DTRACE_TEST_FILES := $(shell ls -1 test/*.test.js | grep -v dtrace | xargs) |
27 | |
28 | |
29 |
#---- Targets |
30 | |
31 |
all $(NODEUNIT): |
32 |
npm install $(NPM_INSTALL_FLAGS) |
33 | |
34 |
# Ensure all version-carrying files have the same version. |
35 |
.PHONY: versioncheck |
36 |
versioncheck: |
37 |
@echo version is: $(shell cat package.json | json version) |
38 |
[[ `cat package.json | json version` == `grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $$2}'` ]] |
39 |
[[ `cat package.json | json version` == `grep '^var VERSION' bin/bunyan | awk -F"'" '{print $$2}'` ]] |
40 |
[[ `cat package.json | json version` == `grep '^var VERSION' lib/bunyan.js | awk -F"'" '{print $$2}'` ]] |
41 |
@echo Version check ok. |
42 | |
43 |
.PHONY: cutarelease |
44 |
cutarelease: check |
45 |
[[ -z `git status --short` ]] # If this fails, the working dir is dirty. |
46 |
@which json 2>/dev/null 1>/dev/null && \ |
47 |
ver=$(shell json -f package.json version) && \ |
48 |
name=$(shell json -f package.json name) && \ |
49 |
publishedVer=$(shell npm view -j $(shell json -f package.json name)@$(shell json -f package.json version) version 2>/dev/null) && \ |
50 |
if [[ -n "$$publishedVer" ]]; then \ |
51 |
echo "error: $$name@$$ver is already published to npm"; \ |
52 |
exit 1; \ |
53 |
fi && \ |
54 |
echo "** Are you sure you want to tag and publish $$name@$$ver to npm?" && \ |
55 |
echo "** Enter to continue, Ctrl+C to abort." && \ |
56 |
read |
57 |
ver=$(shell cat package.json | json version) && \ |
58 |
date=$(shell date -u "+%Y-%m-%d") && \ |
59 |
git tag -a "$$ver" -m "version $$ver ($$date)" && \ |
60 |
git push --tags origin && \ |
61 |
npm publish |
62 | |
63 |
.PHONY: docs |
64 |
docs: toc |
65 |
@[[ `which ronn` ]] || (echo "No 'ronn' on your PATH. Install with 'gem install ronn'" && exit 2) |
66 |
mkdir -p man/man1 |
67 |
ronn --style=toc --manual="bunyan manual" --date=$(shell git log -1 --pretty=format:%cd --date=short) --roff --html docs/bunyan.1.ronn |
68 |
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)' |
69 |
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)' |
70 |
@echo "# test with 'man ./docs/bunyan.1' and 'open ./docs/bunyan.1.html'" |
71 | |
72 |
# Re-generate the README.md table of contents. |
73 |
toc: |
74 |
./node_modules/.bin/markdown-toc -i README.md |
75 | |
76 | |
77 |
.PHONY: publish |
78 |
publish: |
79 |
mkdir -p tmp |
80 |
[[ -d tmp/bunyan-gh-pages ]] || git clone git@github.com:trentm/node-bunyan.git tmp/bunyan-gh-pages |
81 |
cd tmp/bunyan-gh-pages && git checkout gh-pages && git pull --rebase origin gh-pages |
82 |
cp docs/index.html tmp/bunyan-gh-pages/index.html |
83 |
cp docs/bunyan.1.html tmp/bunyan-gh-pages/bunyan.1.html |
84 |
(cd tmp/bunyan-gh-pages \ |
85 |
&& git commit -a -m "publish latest docs" \ |
86 |
&& git push origin gh-pages || true) |
87 | |
88 |
.PHONY: distclean |
89 |
distclean: |
90 |
rm -rf node_modules |
91 | |
92 | |
93 |
#---- test |
94 | |
95 |
.PHONY: test |
96 |
test: $(NODEUNIT) |
97 |
test -z "$(DTRACE_UP_IN_HERE)" || test -n "$(SKIP_DTRACE)" || \ |
98 |
(node -e 'require("dtrace-provider").createDTraceProvider("isthisthingon")' && \ |
99 |
echo "\nNote: Use 'SKIP_DTRACE=1 make test' to skip parts of the test suite that require root." && \ |
100 |
$(SUDO) $(NODEUNIT) test/dtrace.test.js) |
101 |
$(NODEUNIT) $(NON_DTRACE_TEST_FILES) |
102 | |
103 |
# Test will all node supported versions (presumes install locations I use on |
104 |
# my machine -- "~/opt/node-VER"): |
105 |
# Note: 'test4' is last so (if all is well) I end up with a binary |
106 |
# dtrace-provider build for my current default node version. |
107 |
.PHONY: testall |
108 |
testall: test7 test6 test012 test010 test4 |
109 | |
110 |
.PHONY: test7 |
111 |
test7: |
112 |
@echo "# Test node 7.x (with node `$(NODEOPT)/node-7/bin/node --version`)" |
113 |
@$(NODEOPT)/node-7/bin/node --version | grep '^v7\.' |
114 |
PATH="$(NODEOPT)/node-7/bin:$(PATH)" make distclean all test |
115 |
.PHONY: test6 |
116 |
test6: |
117 |
@echo "# Test node 6.x (with node `$(NODEOPT)/node-6/bin/node --version`)" |
118 |
@$(NODEOPT)/node-6/bin/node --version | grep '^v6\.' |
119 |
PATH="$(NODEOPT)/node-6/bin:$(PATH)" make distclean all test |
120 |
.PHONY: test4 |
121 |
test4: |
122 |
@echo "# Test node 4.x (with node `$(NODEOPT)/node-4/bin/node --version`)" |
123 |
@$(NODEOPT)/node-4/bin/node --version | grep '^v4\.' |
124 |
PATH="$(NODEOPT)/node-4/bin:$(PATH)" make distclean all test |
125 |
.PHONY: test012 |
126 |
test012: |
127 |
@echo "# Test node 0.12.x (with node `$(NODEOPT)/node-0.12/bin/node --version`)" |
128 |
@$(NODEOPT)/node-0.12/bin/node --version | grep '^v0\.12\.' |
129 |
PATH="$(NODEOPT)/node-0.12/bin:$(PATH)" make distclean all test |
130 |
.PHONY: test010 |
131 |
test010: |
132 |
@echo "# Test node 0.10.x (with node `$(NODEOPT)/node-0.10/bin/node --version`)" |
133 |
@$(NODEOPT)/node-0.10/bin/node --version | grep '^v0\.10\.' |
134 |
PATH="$(NODEOPT)/node-0.10/bin:$(PATH)" make distclean all test |
135 | |
136 | |
137 |
#---- check |
138 | |
139 |
.PHONY: check-jsstyle |
140 |
check-jsstyle: $(JSSTYLE_FILES) |
141 |
./tools/jsstyle -o indent=4,doxygen,unparenthesized-return=0,blank-after-start-comment=0,leading-right-paren-ok=1 $(JSSTYLE_FILES) |
142 | |
143 |
.PHONY: check |
144 |
check: check-jsstyle versioncheck |
145 |
@echo "Check ok." |
146 | |
147 |
.PHONY: prepush |
148 |
prepush: check testall |
149 |
@echo "Okay to push." |