Comparing version 0.0.12 to 0.0.13
@@ -17,2 +17,3 @@ var util = require("util"), | ||
this.uglyOutput = false; | ||
this.leadingComma = false; | ||
this.inspectOutput = false; | ||
@@ -44,2 +45,3 @@ this.headerPassthrough = false; | ||
console.log(" -u print ugly json output, each object on a single line\n"); | ||
console.log(" -, print leading-comma diff-friendly output, one line per property\n"); | ||
console.log(" -d print debugging output including exception messages\n"); | ||
@@ -83,2 +85,3 @@ console.log(" -o object.path specify the path to an array to be iterated on\n"); | ||
return( this.inspectOutput ? util.inspect(obj, false, Infinity, true) | ||
: this.leadingComma ? this.diffFriendly(obj) | ||
: this.uglyOutput ? JSON.stringify(obj) | ||
@@ -88,2 +91,8 @@ : JSON.stringify(obj, null, 2) ); | ||
JSON.Command.prototype.diffFriendly = function(obj) { | ||
return JSON.stringify(obj, null, 2) | ||
.replace(/ ?([[{,])\n ( *)(?: )/gm, '\n$2$1 ') | ||
.replace(/(^|, ?)\n *{/gm, '$1{'); | ||
}; | ||
JSON.Command.prototype.debug = function(msg) { | ||
@@ -136,2 +145,5 @@ if (this.debugOn) { console.log(msg); } | ||
break; | ||
case "-,": // diff-friendlier output | ||
this.leadingComma = true; | ||
break; | ||
case "-c": // conditional | ||
@@ -138,0 +150,0 @@ this.conditionals.push(a.shift()); |
{ "name": "json" | ||
, "version": "0.0.12" | ||
, "version": "0.0.13" | ||
, "engines": [ "node >=0.4.0" ] | ||
, "description": "JSON command line processing toolkit." | ||
, "author": "Zachary Poley <zpoley@gmail.com> (http://zpoley.net)" | ||
, "contributors": [ "Isaac Schlueter <i@izs.me> (http://blog.izs.me)", "Andrey Tarantsov <andreyvit@gmail.com> (http://www.tarantsov.com/)", "Niek Schmoller <niek.schmoller@helderberg.nl> (http://helderberg.nl)", "Ryunosuke SATO (http://d.hatena.ne.jp/tricknotes/)" ] | ||
, "contributors": [ "Isaac Schlueter <i@izs.me> (http://blog.izs.me)", "Andrey Tarantsov <andreyvit@gmail.com> (http://www.tarantsov.com/)", "Niek Schmoller <niek.schmoller@helderberg.nl> (http://helderberg.nl)", "Ryunosuke SATO (http://d.hatena.ne.jp/tricknotes/)", "Johan Sundström (http://ecmanaut.blogspot.com/)" ] | ||
, "keywords" : [ "json", "command", "shell" ] | ||
@@ -8,0 +8,0 @@ , "man" : "./man/json.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28740
545