Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #1925 Respect --json in view

  • Loading branch information...
commit 89bd08681f720ad27a68045da4e958c51734a59c 1 parent b35503a
@isaacs isaacs authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/view.js
View
7 lib/view.js
@@ -189,7 +189,12 @@ function printData (data, name, cb) {
fields.forEach(function (f) {
var d = cleanup(data[v][f])
if (showVersions || showFields || typeof d !== "string") {
- d = util.inspect(cleanup(data[v][f]), false, 5, npm.color)
+ d = cleanup(data[v][f])
+ d = npm.config.get("json")
+ ? JSON.stringify(d, null, 2)
+ : util.inspect(d, false, 5, npm.color)
+ } else if (typeof d === "string" && npm.config.get("json")) {
+ d = JSON.stringify(d)
}
if (f && showFields) f += " = "
if (d.indexOf("\n") !== -1) d = "\n" + d
Please sign in to comment.
Something went wrong with that request. Please try again.