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-08-29 03:25:43 +0400
committerisaacs <i@izs.me>2010-08-29 03:25:43 +0400
commitec8942b1fc8b0de600e6f60fbdddd3620fc47fd2 (patch)
treea0d06d07f36518e99cdb1928e466197585b4a8ea /cli.js
parent310f3759abb387c7def4910452f8c05c69ecbda9 (diff)
Handle errors a little more DRYly.
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/cli.js b/cli.js
index 85ef254c4..b6aa36dad 100755
--- a/cli.js
+++ b/cli.js
@@ -70,7 +70,7 @@ if (!command && !conf.help) {
+ " npm [flags] <command> [args]\n"
+ "Check 'npm help' for more information\n\n"
)
- process.exit(1)
+ exit(1)
} else itWorked = true
} else {
ini.resolveConfigs(conf, function (er) {
@@ -88,9 +88,10 @@ function errorHandler (er) {
if (!er) {
itWorked = true
log.win("ok")
- return rm(npm.tmp, function (er) { process.exit(0) })
+ return exit(0)
}
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:"
@@ -105,6 +106,9 @@ function errorHandler (er) {
,"or email it to <npm-@googlegroups.com>"
].join("\n"))
}
- rm(npm.tmp, function (er) { process.exit(1) })
+ exit(1)
}
+function exit (code) {
+ rm(npm.tmp, function () { process.exit(code) })
+}