Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle general errors in `npm test`

When creating a new package, I accidentally omitted required `version`
field in my `package.json`. `npm` only told me that test failed.
  • Loading branch information...
commit 2478b6aef2df8ed964b3f2a06851c6afbc311f59 1 parent a8d986e
@mmalecki authored
Showing with 9 additions and 6 deletions.
  1. +1 −1  lib/test.js
  2. +8 −5 lib/utils/exec.js
View
2  lib/test.js
@@ -6,6 +6,6 @@ var testCmd = require("./utils/lifecycle.js").cmd("test")
function test (args, cb) {
testCmd(args, function (er) {
if (!er) return cb()
- return cb("Test failed. See above for more details.")
+ return cb(er.code ? "Test failed. See above for more details." : er)
})
}
View
13 lib/utils/exec.js
@@ -53,11 +53,14 @@ function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) {
})
cp.on("exit", function (code) {
var er = null
- if (code) er = new Error("`"+cmd
- +(args.length ? " "
- + args.map(JSON.stringify).join(" ")
- : "")
- +"` failed with "+code)
+ if (code) {
+ er = new Error("`"+cmd
+ +(args.length ? " "
+ + args.map(JSON.stringify).join(" ")
+ : "")
+ +"` failed with "+code)
+ er.code = code
+ }
cb(er, code, stdout, stderr)
})
return cp
Please sign in to comment.
Something went wrong with that request. Please try again.