Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cli.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-07-05 09:03:15 +0400
committerisaacs <i@izs.me>2010-07-25 05:51:17 +0400
commit01ec10f5afe155ba7a669e47d13c199daf0bc499 (patch)
tree99b1930bd0eb9818902360c51721df5c3c7ea45a /cli.js
parent9fe57adffa4364ec5c260f66fa4605ccb127fd0d (diff)
Manually exit if necessary, and say "not ok" when not ok
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js25
1 files changed, 16 insertions, 9 deletions
diff --git a/cli.js b/cli.js
index 879017620..b1016ff16 100755
--- a/cli.js
+++ b/cli.js
@@ -51,6 +51,9 @@ if (printVersion) {
} else log(npm.version, "version")
process.on("uncaughtException", errorHandler)
+process.on("exit", function () { if (!itWorked) log("not ok") })
+
+var itWorked = false
if (!command) { if (!printVersion) {
// npm.commands.help([arglist.join(" ")])
@@ -65,14 +68,18 @@ if (!command) { if (!printVersion) {
}} else npm.commands[command](arglist, errorHandler)
function errorHandler (er) {
- if (er) {
- sys.error("")
- log(er, "!")
- sys.error("")
- log("try running: 'npm help "+command+"'", "failure")
- log("Report this *entire* log at <http://github.com/isaacs/npm/issues>", "failure")
- log("or email it to <npm-@googlegroups.com>", "failure")
- process.exit(1)
- } else log("ok")
+ if (!er) {
+ itWorked = true
+ log("ok")
+ if (npm.SHOULD_EXIT) process.exit()
+ return
+ }
+ sys.error("")
+ log(er, "!")
+ sys.error("")
+ log("try running: 'npm help "+command+"'", "failure")
+ log("Report this *entire* log at <http://github.com/isaacs/npm/issues>", "failure")
+ log("or email it to <npm-@googlegroups.com>", "failure")
+ process.exit(1)
}