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-09-21 05:23:13 +0400
committerisaacs <i@izs.me>2010-09-21 05:23:13 +0400
commitf9071cfbfd5b3316d9f4f18e06e75358bb757703 (patch)
treebc98b78f9b05f1e9af6230cd238cf4221fbf71cd /cli.js
parent165cfda698fcc36b70ff535a35ec0297eccd25a4 (diff)
Throw an error if the cb is called more than once.
Diffstat (limited to 'cli.js')
-rwxr-xr-xcli.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/cli.js b/cli.js
index 944bce743..02a8f3071 100755
--- a/cli.js
+++ b/cli.js
@@ -94,11 +94,14 @@ if (!command && !conf.help) {
})
}
+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(0)
+ return exit()
}
log.error(er)
if (!(er instanceof Error)) return exit(1)
@@ -120,5 +123,5 @@ function errorHandler (er) {
}
function exit (code) {
- rm(npm.tmp, function () { process.exit(code) })
+ rm(npm.tmp, function () { process.exit(code || 0) })
}