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
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2010-08-24 07:35:10 +0400
committerisaacs <i@izs.me>2010-08-24 07:35:10 +0400
commit0930d67ec01f0c24acc2c7c0e7f228cd90b15c23 (patch)
treecfc908233253d06b3098e3a4a49e8cbc96db37a0
parentc9328292fb35ad6421efd85c4a19f694216ace90 (diff)
log configgy pudding
-rwxr-xr-xcli.js8
-rw-r--r--lib/build.js1
-rw-r--r--lib/uninstall.js2
-rw-r--r--lib/utils/fetch.js21
-rw-r--r--lib/utils/log.js3
-rw-r--r--lib/utils/registry/request.js2
6 files changed, 19 insertions, 18 deletions
diff --git a/cli.js b/cli.js
index 303b5b2e3..9b59d446d 100755
--- a/cli.js
+++ b/cli.js
@@ -4,7 +4,7 @@
// might conceivably be a bootstrap attempt.
var log = require("./lib/utils/log")
-log("ok", "it worked if it ends with")
+log.info("ok", "it worked if it ends with")
var fs = require("./lib/utils/graceful-fs")
, path = require("path")
@@ -23,7 +23,7 @@ var fs = require("./lib/utils/graceful-fs")
, command
, flagsDone
-log(argv, "cli")
+log.verbose(argv, "cli")
while (arg = argv.shift()) {
if (!key && (arg === "-h" || arg === "-?")) arg = "--help"
@@ -54,7 +54,7 @@ if (printVersion) {
} else log(npm.version, "version")
process.on("uncaughtException", errorHandler)
-process.on("exit", function () { if (!itWorked) log("not ok") })
+process.on("exit", function () { if (!itWorked) log.win("not ok") })
var itWorked = false
@@ -85,7 +85,7 @@ if (!command && !conf.help) {
function errorHandler (er) {
if (!er) {
itWorked = true
- log("ok")
+ log.win("ok")
return rm(npm.tmp, function (er) { process.exit(0) })
}
log.error(er)
diff --git a/lib/build.js b/lib/build.js
index bba79b203..1ee2ec91f 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -211,6 +211,7 @@ function linkModules (pkg, target, cb) {
// shim ROOT/{name}-{version}/**/*.js to ROOT/.npm/{name}/{version}/{lib}/**/*.js
function linkDefaultModules(pkg, lib, target, cb) {
+ log.warn("linking default modules", pkg._id)
var pkgDir = path.join(npm.dir, pkg.name, pkg.version, "package")
, libDir = path.join(pkgDir, lib)
diff --git a/lib/uninstall.js b/lib/uninstall.js
index 33faf908e..04c4103f4 100644
--- a/lib/uninstall.js
+++ b/lib/uninstall.js
@@ -43,7 +43,7 @@ function unpackArgs (rawArgs, cb) {
var args = []
, argData = []
rawArgs.forEach(function (arg) {
- arg = arg.split("@")
+ arg = Array.isArray(arg) ? arg : arg.split("@")
var ver = arg[1] || ""
, pkg = arg[0] || ""
arg = arg.join("@")
diff --git a/lib/utils/fetch.js b/lib/utils/fetch.js
index 8897e0781..d6fdd3de1 100644
--- a/lib/utils/fetch.js
+++ b/lib/utils/fetch.js
@@ -15,8 +15,8 @@ var http = require("http")
module.exports = fetch
function fetch (remote, local, headers, cb) {
if (!cb) cb = headers, headers = {}
- log(remote, "fetch")
- log(local, "fetch")
+ log.info(remote, "fetch")
+ log.verbose(local, "fetch to")
headers.host = url.parse(remote).hostname
fs.open(local, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, 0755,
function (er, fd) {
@@ -56,7 +56,7 @@ function fetchAndWrite (remote, fd, headers, maxRedirects, redirects, cb) {
cookie = (cookie + "").split(";").shift()
set(headers, "Cookie", cookie)
}
- log(response.statusCode+" "+loc, "fetch")
+ log.verbose(response.statusCode+" "+loc, "fetch")
return fetchAndWrite(loc, fd, headers, maxRedirects, redirects + 1, cb)
}
if (response.statusCode !== 200) {
@@ -67,14 +67,14 @@ function fetchAndWrite (remote, fd, headers, maxRedirects, redirects, cb) {
, len = response.headers["content-length"]
, pct = 0
, lastPct = 0
- log(len || "unknown", "content-length")
+ log.verbose(len || "unknown", "content-length")
response.on("data", function (chunk) {
// write the chunk...
written += chunk.length
if (len) {
pct = written / len * 100
if (lastPct === 0 || (pct - lastPct > 10)) {
- log(Math.round(pct)+"%", "downloaded")
+ log.verbose(Math.round(pct)+"%", "downloaded")
lastPct = pct
}
}
@@ -86,8 +86,7 @@ function fetchAndWrite (remote, fd, headers, maxRedirects, redirects, cb) {
})
response.on("error", cb)
response.on("end", function () {
- log("finished", "fetch")
- log(written, "bytes")
+ log.verbose(remote.href+" - "+written+" bytes", "fetched")
fs.close(fd, cb)
})
})
@@ -108,16 +107,16 @@ urls.forEach(function (url) {
var fetchFile = path.basename(url, ".tgz")+"-fetch.tgz"
, wgetFile = path.basename(url, ".tgz")+"-wget.tgz"
fetch(url, fetchFile, function (e) {
- if (e) { log(e, fetchFile) ; throw e }
+ if (e) { log.error(e, fetchFile) ; throw e }
exec( "wget"
, ["-O", wgetFile, url]
, null, true
, function (er, code, stdout, stderr) {
- if (e) { log(e, wgetFile) ; throw e }
+ if (e) { log.error(e, wgetFile) ; throw e }
exec("md5", ["-q", wgetFile], null, true, function (er, _, wghash, __) {
- if (e) { log(e, "md5 "+wgetFile) ; throw e }
+ if (e) { log.error(e, "md5 "+wgetFile) ; throw e }
exec("md5", ["-q", fetchFile], null, true, function (er, _, fhash, __) {
- if (e) { log(e, "md5 "+fetchFile) ; throw e }
+ if (e) { log.error(e, "md5 "+fetchFile) ; throw e }
assert.equal(wghash, fhash, fetchFile + " == " + wgetFile)
})
})
diff --git a/lib/utils/log.js b/lib/utils/log.js
index 827c32c66..dc66a014c 100644
--- a/lib/utils/log.js
+++ b/lib/utils/log.js
@@ -48,7 +48,8 @@ Object.keys(LEVEL).forEach(function (l) {
LEVEL[LEVEL[l]] = l
LEVEL[l.toLowerCase()] = LEVEL[l]
if (l === "silent") return
- log[l] = function (msg, pref, cb) { return log(msg, pref, l, cb) }
+ log[l] = log[l.toLowerCase()] =
+ function (msg, pref, cb) { return log(msg, pref, l, cb) }
})
// COLOR[LEVEL.verbose] = '0'
COLOR[LEVEL.info] = 32
diff --git a/lib/utils/registry/request.js b/lib/utils/registry/request.js
index cd68529ed..05c645357 100644
--- a/lib/utils/registry/request.js
+++ b/lib/utils/registry/request.js
@@ -133,7 +133,7 @@ function upload (where, filename, cb) {
new File(filename, function (er, f) {
if (er) return log.er(cb, "Couldn't open "+filename)(er)
PUT(where, f, function (er) {
- log("done with upload")
+ log.info("done with upload", "publish")
cb(er)
})
})