Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

use archy in install

  • Loading branch information...
commit 27663a4dd2645323149123a74cb0507b80fdc188 1 parent a12e876
Isaac Z. Schlueter authored March 27, 2012

Showing 1 changed file with 14 additions and 17 deletions. Show diff stats Hide diff stats

  1. 31  lib/install.js
31  lib/install.js
... ...
@@ -1,4 +1,3 @@
1  
-
2 1
 // npm install <pkg> <pkg> <pkg>
3 2
 //
4 3
 // See doc/install.md for more description
@@ -70,6 +69,7 @@ var npm = require("./npm.js")
70 69
   , url = require("url")
71 70
   , mkdir = require("./utils/mkdir-p.js")
72 71
   , lifecycle = require("./utils/lifecycle.js")
  72
+  , archy = require("archy")
73 73
 
74 74
 function install (args, cb_) {
75 75
 
@@ -281,23 +281,20 @@ function prettify (tree, installed) {
281 281
   // XXX This should match the data structure provided by npm ls --json
282 282
   if (npm.config.get("json")) return JSON.stringify(tree, null, 2)
283 283
   if (npm.config.get("parseable")) return parseable(installed)
284  
-  return Object.keys(tree).map(function (p) {
285  
-    p = tree[p]
286  
-    var c = ""
287  
-    if (p.children && p.children.length) {
288  
-      pref = "\n"
289  
-      var l = p.children.pop()
290  
-      c = p.children.map(function (c) {
291  
-        var gc = c.children && c.children.length
292  
-               ? " (" + c.children.map(function (gc) {
293  
-                   return gc.what
294  
-                 }).join(" ") + ")"
295  
-               : ""
296  
-        return "\n├── " + c.what + gc
297  
-      }).join("") + "\n└── " + l.what
298  
-    }
299  
-    return [p.what, p.where, c].join(" ")
300 284
 
  285
+  return Object.keys(tree).map(function (p) {
  286
+    return archy({ label: tree[p].what + " " + p
  287
+                 , nodes: (tree[p].children || []).map(function P (c) {
  288
+                     if (npm.config.get("long")) {
  289
+                       return { label: c.what, nodes: c.children.map(P) }
  290
+                     }
  291
+                     var g = c.children.map(function (g) {
  292
+                       return g.what
  293
+                     }).join(", ")
  294
+                     if (g) g = " (" + g + ")"
  295
+                     return c.what + g
  296
+                   })
  297
+                 })
301 298
   }).join("\n")
302 299
 }
303 300
 

0 notes on commit 27663a4

Please sign in to comment.
Something went wrong with that request. Please try again.