Permalink
Browse files

issue#16: cannot use regex as a function in v8 used in node v0.5

  • Loading branch information...
trentm committed Aug 3, 2011
1 parent 0097b50 commit 5b2fc3b79fe5799792902d38f53b6468c1310062
Showing with 32 additions and 14 deletions.
  1. +1 −0 .gitignore
  2. +6 −0 CHANGES.md
  3. +7 −2 Makefile
  4. +1 −0 TODO.md
  5. +3 −3 lib/jsontool.js
  6. +3 −2 package.json
  7. +8 −5 test/Makefile
  8. +2 −1 test/quiet/cmd
  9. +1 −1 test/quiet/expected.stdout
View
@@ -1 +1,2 @@
/tmp
+/node_modules
View
@@ -1,5 +1,11 @@
# json (aka jsontool) Changelog
+## json v1.3.2
+
+- [issues #16] Fix to use `<regex object>.exec` instead of using the regex
+ object as a function -- no longer allowed in the v8 used in node v0.5.x.
+
+
## json v1.3.1
- Make "jsontool" require'able as a module. For example, you can now:
View
@@ -5,12 +5,17 @@ help:
@echo "test run the test suite"
@echo "tag create a git tag for current version"
-docs:
+node_modules/.bin/ronn:
+ npm install
+node_modules/.bin/nodeunit:
+ npm install
+
+docs: node_modules/.bin/ronn
mkdir -p man/man1
node_modules/.bin/ronn -r json.1.ronn > man/man1/json.1
@echo "# test with 'man man/man1/json.1'"
-test:
+test: node_modules/.bin/nodeunit
(cd test && make test)
testall:
(cd test && make testall)
View
@@ -1,3 +1,4 @@
+- make testall: need a version of nodeunit that doesn't use "require.paths": no longer in v0.5
- npm/lib/utils/minimatch.js: fnmatch/glob implementation.
Use that for more generic "*.foo" or "*.{foo,bar}" matching. Says Isaac: "it'd be cool :)".
https://github.com/isaacs/npm/blob/master/lib/utils/minimatch.js
View
@@ -5,7 +5,7 @@
// See <https://github.com/trentm/json>.
//
-var VERSION = "1.3.1";
+var VERSION = "1.3.2";
var sys = require('sys');
var runInNewContext;
@@ -271,7 +271,7 @@ function processDatum(datum, args) {
var bit = bits[i];
if (bit[0] === '[') {
lookup += bit;
- } else if (! isJSIdentifier(bits[i])) {
+ } else if (! isJSIdentifier.exec(bits[i])) {
// Allow a non-JS-indentifier token, e.g. `json foo-bar`.
lookup += '["' + bits[i].replace('"', '\\"') + '"]';
} else {
@@ -319,7 +319,7 @@ function processDatumExperimental(datum, args) {
data = newdata;
} else if (bit[0] === '[') {
lookup += bit;
- } else if (! isJSIdentifier(bits[i])) {
+ } else if (! isJSIdentifier.exec(bits[i])) {
// Allow a non-JS-indentifier token, e.g. `json foo-bar`.
lookup += '["' + bits[i].replace('"', '\\"') + '"]';
} else {
View
@@ -1,7 +1,7 @@
{
"name": "jsontool",
"description": "a 'json' command for massaging JSON on your Unix command line",
- "version": "1.3.1",
+ "version": "1.3.2",
"repository": {
"type": "git",
"url": "git://github.com/trentm/json.git"
@@ -20,7 +20,8 @@
"engines": ["node >=0.2.0"],
"keywords": ["json", "jsontool", "filter", "command", "shell"],
"devDependencies": {
- "nodeunit": "0.5"
+ "nodeunit": "0.5",
+ "ronn": "0.3.6"
}
}
View
@@ -1,20 +1,23 @@
+
+NODEUNIT=../node_modules/.bin/nodeunit
+
test:
- NODE_PATH=node_modules node_modules/.bin/nodeunit test.js
+ NODE_PATH=node_modules $(NODEUNIT) test.js
# Test will all node versions (presumes install locations I use on my machine).
testall: test05 test04 test03
test05:
- NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.5/bin:$(PATH)" node_modules/.bin/nodeunit test.js
+ NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.5/bin:$(PATH)" $(NODEUNIT) test.js
test04:
- NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.4/bin:$(PATH)" node_modules/.bin/nodeunit test.js
+ NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.4/bin:$(PATH)" $(NODEUNIT) test.js
test03:
- NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.3/bin:$(PATH)" node_modules/.bin/nodeunit test.js
+ NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.3/bin:$(PATH)" $(NODEUNIT) test.js
test02:
@echo "* * *"
@echo "It is a known issue that test 'utf8' fails with node 0.2. Don't use node 0.2. :)"
@echo "* * *"
- NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.2/bin:$(PATH)" node_modules/.bin/nodeunit test.js
+ NODE_PATH=node_modules PATH="$(HOME)/opt/node-0.2/bin:$(PATH)" $(NODEUNIT) test.js
.PHONY: test
View
@@ -1,5 +1,6 @@
echo "# no args"
-cat input | ../../lib/jsontool.js 2>&1
+# `cut` to avoid v8 version diffs in the SyntaxError message.
+cat input | ../../lib/jsontool.js 2>&1 | cut -c 1-49
echo "# -q"
cat input | ../../lib/jsontool.js -q 2>&1
echo "# --quiet"
@@ -1,5 +1,5 @@
# no args
-json: error: doesn't look like JSON: SyntaxError: Unexpected token ILLEGAL (buffer="{'foo'}\n")
+json: error: doesn't look like JSON: SyntaxError:
{'foo'}
# -q
{'foo'}

0 comments on commit 5b2fc3b

Please sign in to comment.