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-10-02 12:16:31 +0400
committerisaacs <i@izs.me>2010-10-02 12:20:49 +0400
commitc445a291a51d0cafdf453b61d6e129749dc10120 (patch)
tree8d86f77dcf944b055621417b4ade8edd3568a507 /cli.js
parenta72ebbde52a7c86d64982fae5aa6179e9c16b946 (diff)
Move error handling into a separate file, and add more support for common issues.
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js40
1 files changed, 1 insertions, 39 deletions
diff --git a/cli.js b/cli.js
index 0cfe744e0..d74a88e98 100755
--- a/cli.js
+++ b/cli.js
@@ -12,6 +12,7 @@ var fs = require("./lib/utils/graceful-fs")
, npm = require("./npm")
, ini = require("./lib/utils/ini")
, rm = require("./lib/utils/rm-rf")
+ , errorHandler = require("./lib/utils/error-handler")
// supported commands.
, argv = process.argv.slice(2)
@@ -64,10 +65,6 @@ if (!semver.satisfies(nodeVer, reqVer)) {
}
process.on("uncaughtException", errorHandler)
-process.on("exit", function () { if (!itWorked) log.win("not ok") })
-
-var itWorked = false
-
if (!command && !printVersion) conf.usage = true
@@ -83,38 +80,3 @@ else {
npm.commands[command](arglist, errorHandler)
})
}
-
-var cbCalled = false
-function errorHandler (er) {
- if (cbCalled) throw new Error("Callback called more than once.")
- cbCalled = true
- if (!er) {
- itWorked = true
- log.win("ok")
- return exit()
- }
- log.error(er)
- if (!(er instanceof Error)) return exit(1)
- if (er.message.trim() === "ECONNREFUSED, Could not contact DNS servers") {
- log.error(["If you are using Cygwin, please set up your /etc/resolv.conf"
- ,"See step 3 in this wiki page:"
- ," http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29"
- ,"If you are not using Cygwin, please report this"
- ,"at <http://github.com/isaacs/npm/issues>"
- ,"or email it to <npm-@googlegroups.com>"
- ].join("\n"))
- } else {
- if (npm.commands[command].usage) {
- log.error(npm.commands[command].usage)
- }
- log.error(["try running: 'npm help "+command+"'"
- ,"Report this *entire* log at <http://github.com/isaacs/npm/issues>"
- ,"or email it to <npm-@googlegroups.com>"
- ].join("\n"))
- }
- exit(1)
-}
-
-function exit (code) {
- rm(npm.tmp, function () { process.exit(code || 0) })
-}