Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
ls: Exit with error when problems are found
Browse files Browse the repository at this point in the history
Fix #2798
  • Loading branch information
isaacs committed Sep 12, 2012
1 parent 3701086 commit 0fc2c2d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/ls.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function ls (args, silent, cb) {
readInstalled(dir, npm.config.get("depth"), function (er, data) { readInstalled(dir, npm.config.get("depth"), function (er, data) {
var bfs = bfsify(data, args) var bfs = bfsify(data, args)
, lite = getLite(bfs) , lite = getLite(bfs)

if (er || silent) return cb(er, data, lite) if (er || silent) return cb(er, data, lite)


var long = npm.config.get("long") var long = npm.config.get("long")
Expand All @@ -58,7 +59,12 @@ function ls (args, silent, cb) {
out = makeArchy(bfs, long, dir) out = makeArchy(bfs, long, dir)
} }
console.log(out) console.log(out)
cb(null, data, lite)
// if any errors were found, then complain and exit status 1
if (lite.problems && lite.problems.length) {
er = lite.problems.join('\n')
}
cb(er, data, lite)
}) })
} }


Expand Down Expand Up @@ -210,7 +216,6 @@ function makeArchy_ (data, long, dir, depth, parent, d) {
if (depth < npm.config.get("depth")) { if (depth < npm.config.get("depth")) {
// just missing // just missing
var p = parent.link || parent.path var p = parent.link || parent.path
log.warn("unmet dependency", "%s in %s", d+" "+data, p)
var unmet = "UNMET DEPENDENCY" var unmet = "UNMET DEPENDENCY"
if (color) { if (color) {
unmet = "\033[31;40m" + unmet + "\033[0m" unmet = "\033[31;40m" + unmet + "\033[0m"
Expand Down Expand Up @@ -303,7 +308,6 @@ function makeParseable_ (data, long, dir, depth, parent, d) {
if (typeof data === "string") { if (typeof data === "string") {
if (data.depth < npm.config.get("depth")) { if (data.depth < npm.config.get("depth")) {
var p = parent.link || parent.path var p = parent.link || parent.path
log.warn("unmet dependency", "%s in %s", d+" "+data, p)
data = npm.config.get("long") data = npm.config.get("long")
? path.resolve(parent.path, "node_modules", d) ? path.resolve(parent.path, "node_modules", d)
+ ":"+d+"@"+JSON.stringify(data)+":INVALID:MISSING" + ":"+d+"@"+JSON.stringify(data)+":INVALID:MISSING"
Expand Down

0 comments on commit 0fc2c2d

Please sign in to comment.