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/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-05-08 22:38:21 +0400
committerisaacs <i@izs.me>2010-05-08 22:38:21 +0400
commita1e0250aa32f749e650721f3c85783881e2a0c60 (patch)
tree638f03f59e455870031b692805bcfb705f860892 /lib
parent3421bbe3cba796b5d840f26975470e796f92ffbf (diff)
Add a "log error or continue" function to wrap a callback when no other action is required.
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/log.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils/log.js b/lib/utils/log.js
index 522c5cf3c..143071e99 100644
--- a/lib/utils/log.js
+++ b/lib/utils/log.js
@@ -11,3 +11,11 @@ function log (msg, pref, cb) {
cb && cb()
}
+log.er = function (cb, msg) {
+ if (!msg) throw new Error(
+ "Why bother logging it if you're not going to print a message?")
+ return function (er) {
+ if (er) log(msg, "fail")
+ cb.apply(this, arguments)
+ }
+}