Skip to content

Commit

Permalink
setup for 9.0.5 release; test with more modern node.js versions (0.10…
Browse files Browse the repository at this point in the history
… to 7); fix a test failure due to node 0.12 change in syscall exception message
  • Loading branch information
trentm committed Mar 3, 2017
1 parent d504e2f commit d3d88e1
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 669 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Isaac Schlueter (https://github.com/isaacs)
Andrew O'Brien (https://github.com/AndrewO)
Nate Fitch (https://github.com/nfitch)
https://github.com/inator
Todd Whiteman (https://github.com/twhiteman)
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# json Changelog

## json 9.0.6 (not yet released)
## not yet released

(nothing yet)

Expand Down
77 changes: 62 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#

JSSTYLE_FILES := $(shell find lib test -name "*.js")
NODEUNIT=./node_modules/nodeunit/bin/nodeunit
NODEOPT ?= $(HOME)/opt


#
Expand All @@ -20,13 +22,6 @@ deps/JSON-js/json_parse.js:
git submodule update --init


# Ensure json.js and package.json have the same version.
.PHONY: versioncheck
versioncheck:
@echo version is: $(shell cat package.json | lib/json.js version)
[[ `cat package.json | lib/json.js version` == `grep '^## ' CHANGES.md | head -1 | awk '{print $$3}'` ]]
[[ `cat package.json | lib/json.js version` == `grep '^var VERSION' lib/json.js | awk -F"'" '{print $$2}'` ]]

.PHONY: docs
docs:
@[[ `which ronn` ]] || (echo "No 'ronn' on your PATH. Install with 'gem install ronn'" && exit 2)
Expand All @@ -47,15 +42,60 @@ publish:
&& git commit -a -m "publish latest docs" \
&& git push origin gh-pages || true)

.PHONY: test testall
test: node_modules/.bin/nodeunit
(cd test && make test)
testall: node_modules/.bin/nodeunit
(cd test && make testall)
.PHONY: test
test: | node_modules/.bin/nodeunit
$(NODEUNIT) test/test.js

# Test will all supported node versions (presumes install locations I use on my
# machine).
.PHONY: testall
testall: test7 test6 test012 test010 test4

.PHONY: test7
test7:
@echo "# Test node 7.x (with node `$(NODEOPT)/node-7/bin/node --version`)"
@$(NODEOPT)/node-7/bin/node --version | grep '^v7\.'
PATH="$(NODEOPT)/node-7/bin:$(PATH)" make test
.PHONY: test6
test6:
@echo "# Test node 6.x (with node `$(NODEOPT)/node-6/bin/node --version`)"
@$(NODEOPT)/node-6/bin/node --version | grep '^v6\.'
PATH="$(NODEOPT)/node-6/bin:$(PATH)" make test
.PHONY: test4
test4:
@echo "# Test node 4.x (with node `$(NODEOPT)/node-4/bin/node --version`)"
@$(NODEOPT)/node-4/bin/node --version | grep '^v4\.'
PATH="$(NODEOPT)/node-4/bin:$(PATH)" make test
.PHONY: test012
test012:
@echo "# Test node 0.12.x (with node `$(NODEOPT)/node-0.12/bin/node --version`)"
@$(NODEOPT)/node-0.12/bin/node --version | grep '^v0\.12\.'
PATH="$(NODEOPT)/node-0.12/bin:$(PATH)" make test
.PHONY: test010
test010:
@echo "# Test node 0.10.x (with node `$(NODEOPT)/node-0.10/bin/node --version`)"
@$(NODEOPT)/node-0.10/bin/node --version | grep '^v0\.10\.'
PATH="$(NODEOPT)/node-0.10/bin:$(PATH)" make test

.PHONY: cutarelease
cutarelease: versioncheck
./tools/cutarelease.py -f package.json -f lib/json.js
cutarelease: check-version
[[ -z `git status --short` ]] # If this fails, the working dir is dirty.
@which json 2>/dev/null 1>/dev/null && \
ver=$(shell json -f package.json version) && \
name=$(shell json -f package.json name) && \
publishedVer=$(shell npm view -j $(shell json -f package.json name)@$(shell json -f package.json version) version 2>/dev/null) && \
if [[ -n "$$publishedVer" ]]; then \
echo "error: $$name@$$ver is already published to npm"; \
exit 1; \
fi && \
echo "** Are you sure you want to tag and publish $$name@$$ver to npm?" && \
echo "** Enter to continue, Ctrl+C to abort." && \
read
ver=$(shell cat package.json | json version) && \
date=$(shell date -u "+%Y-%m-%d") && \
git tag -a "$$ver" -m "version $$ver ($$date)" && \
git push --tags origin && \
npm publish

# Update the embedded minified "function json_parse" in lib/json.js.
.PHONY: update_json_parse
Expand All @@ -69,8 +109,15 @@ update_json_parse: deps/JSON-js/json_parse.js node_modules/.bin/uglifyjs
check-jsstyle: $(JSSTYLE_FILES)
./tools/jsstyle -o indent=2,doxygen,unparenthesized-return=0,blank-after-start-comment=0,leading-right-paren-ok $(JSSTYLE_FILES)

# Ensure json.js and package.json have the same version.
.PHONY: check-version
check-version:
@echo version is: $(shell cat package.json | lib/json.js version)
[[ `cat package.json | lib/json.js version` == `grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $$3}'` ]]
[[ `cat package.json | lib/json.js version` == `grep '^var VERSION' lib/json.js | awk -F"'" '{print $$2}'` ]]

.PHONY: check
check: check-jsstyle
check: check-jsstyle check-version
@echo "Check ok."

.PHONY: prepush
Expand Down
8 changes: 4 additions & 4 deletions lib/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* See <https://github.com/trentm/json> and <https://trentm.com/json/>
*/

var VERSION = '9.0.6';
var VERSION = '9.0.5';

var p = console.warn;
var util = require('util');
Expand Down Expand Up @@ -1305,7 +1305,7 @@ function main(argv) {
// streaming
var chunker = chunkEmitter(opts);
chunker.on('error', function (error) {
warn('json: error: %s', err);
warn('json: error: %s', err.message);
return drainStdoutAndExit(1);
});
chunker.on('chunk', parseChunk);
Expand All @@ -1314,7 +1314,7 @@ function main(argv) {
'cannot handle more than one file with -I');
getInput(opts, function (err, content, filename) {
if (err) {
warn('json: error: %s', err)
warn('json: error: %s', err.message)
return drainStdoutAndExit(1);
}

Expand Down Expand Up @@ -1348,7 +1348,7 @@ function main(argv) {
// not streaming
getInput(opts, function (err, buffer, filename) {
if (err) {
warn('json: error: %s', err)
warn('json: error: %s', err.message)
return drainStdoutAndExit(1);
}
// Take off a leading HTTP header if any and pass it through.
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json",
"description": "a 'json' command for massaging and processing JSON on the command line",
"version": "9.0.6",
"version": "9.0.5",
"repository": {
"type": "git",
"url": "git://github.com/trentm/json.git"
Expand All @@ -15,7 +15,9 @@
"scripts": {
"test": "make test"
},
"engines": ["node >=0.6.0"],
"engines": {
"node": ">=0.10.0"
},
"keywords": ["json", "jsontool", "filter", "command", "shell"],
"devDependencies": {
"uglify-js": "1.1.x",
Expand Down
33 changes: 0 additions & 33 deletions test/Makefile

This file was deleted.

9 changes: 7 additions & 2 deletions test/in-place/cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ echo '# http header block'
$JSON -I -f http-header-block.json
cat http-header-block.json

# Node 0.10 and below look like this:
# json: error: Error: ENOENT, no such file or directory 'does-not-exist.json'
# Node 0.12 and above like this:
# json: error: Error: ENOENT: no such file or directory, open 'does-not-exist.json'
# IOW, node's `message` on a open syscall error changed format. We will
# normalize to the newer output form.
echo '# does not exist' >&2
echo '# does not exist'
$JSON -I -f does-not-exist.json
$JSON -I -f does-not-exist.json 2> >(sed -e 's/ENOENT, no such file or directory/ENOENT: no such file or directory, open/' >&2)

echo '# multiple files' >&2
echo '# multiple files'
Expand All @@ -37,4 +43,3 @@ echo '# -c' >&2
echo '# -c'
$JSON -I -f users.json -c 'this.age < 30'
cat users.json

2 changes: 1 addition & 1 deletion test/in-place/expected.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ json: error: "bogus.json" is not JSON: Unexpected 'a' at line 1, column 10:
# http header block
json: updated "http-header-block.json" in-place
# does not exist
json: error: Error: ENOENT, no such file or directory 'does-not-exist.json'
json: error: ENOENT: no such file or directory, open 'does-not-exist.json'
# multiple files
json: error: must specify exactly one file with "-f FILE" to use -I/--in-place
# -e
Expand Down
Loading

0 comments on commit d3d88e1

Please sign in to comment.