Permalink
Browse files

use archy in install

  • Loading branch information...
1 parent a12e876 commit 27663a4dd2645323149123a74cb0507b80fdc188 @isaacs isaacs committed Mar 28, 2012
Showing with 14 additions and 17 deletions.
  1. +14 −17 lib/install.js
View
@@ -1,4 +1,3 @@
-
// npm install <pkg> <pkg> <pkg>
//
// See doc/install.md for more description
@@ -70,6 +69,7 @@ var npm = require("./npm.js")
, url = require("url")
, mkdir = require("./utils/mkdir-p.js")
, lifecycle = require("./utils/lifecycle.js")
+ , archy = require("archy")
function install (args, cb_) {
@@ -281,23 +281,20 @@ function prettify (tree, installed) {
// XXX This should match the data structure provided by npm ls --json
if (npm.config.get("json")) return JSON.stringify(tree, null, 2)
if (npm.config.get("parseable")) return parseable(installed)
- return Object.keys(tree).map(function (p) {
- p = tree[p]
- var c = ""
- if (p.children && p.children.length) {
- pref = "\n"
- var l = p.children.pop()
- c = p.children.map(function (c) {
- var gc = c.children && c.children.length
- ? " (" + c.children.map(function (gc) {
- return gc.what
- }).join(" ") + ")"
- : ""
- return "\n├── " + c.what + gc
- }).join("") + "\n└── " + l.what
- }
- return [p.what, p.where, c].join(" ")
+ return Object.keys(tree).map(function (p) {
+ return archy({ label: tree[p].what + " " + p
+ , nodes: (tree[p].children || []).map(function P (c) {
+ if (npm.config.get("long")) {
+ return { label: c.what, nodes: c.children.map(P) }
+ }
+ var g = c.children.map(function (g) {
+ return g.what
+ }).join(", ")
+ if (g) g = " (" + g + ")"
+ return c.what + g
+ })
+ })
}).join("\n")
}

0 comments on commit 27663a4

Please sign in to comment.