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:
-rw-r--r--lib/bin.js13
-rw-r--r--lib/build.js4
-rw-r--r--lib/cache.js9
-rw-r--r--lib/completion.js7
-rw-r--r--lib/config.js10
-rw-r--r--lib/help-search.js19
-rw-r--r--lib/help.js12
-rw-r--r--lib/install.js13
-rw-r--r--lib/link.js8
-rw-r--r--lib/ls.js23
-rw-r--r--lib/outdated.js7
-rw-r--r--lib/owner.js5
-rw-r--r--lib/pack.js4
-rw-r--r--lib/prefix.js7
-rw-r--r--lib/publish.js4
-rw-r--r--lib/rebuild.js6
-rw-r--r--lib/root.js7
-rw-r--r--lib/search.js20
-rw-r--r--lib/shrinkwrap.js6
-rw-r--r--lib/star.js3
-rw-r--r--lib/submodule.js1
-rw-r--r--lib/unpublish.js4
-rw-r--r--lib/utils/lifecycle.js48
-rw-r--r--lib/view.js7
-rw-r--r--lib/whoami.js9
25 files changed, 130 insertions, 126 deletions
diff --git a/lib/bin.js b/lib/bin.js
index bd82bc9e3..719e8870d 100644
--- a/lib/bin.js
+++ b/lib/bin.js
@@ -1,19 +1,18 @@
module.exports = bin
var npm = require("./npm.js")
- , output = require("./utils/output.js")
bin.usage = "npm bin\nnpm bin -g\n(just prints the bin folder)"
-function bin (args, cb) {
- var path = require("path")
- , b = npm.bin
+function bin (args, silent, cb) {
+ if (typeof cb !== "function") cb = silent, silent = false
+ var b = npm.bin
, PATH = (process.env.PATH || "").split(":")
- output.write(b, function (er) { cb(er, b) })
+ if (!silent) console.log(b)
+ process.nextTick(cb.bind(this, null, b))
if (npm.config.get("global") && PATH.indexOf(b) === -1) {
- output.write("(not in PATH env variable)"
- ,npm.config.get("logfd"))
+ npm.config.get("logstream").write("(not in PATH env variable)\n")
}
}
diff --git a/lib/build.js b/lib/build.js
index 9d1a99111..fd55b9e9b 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -20,7 +20,6 @@ var npm = require("./npm.js")
, cmdShim = require("./utils/cmd-shim.js")
, cmdShimIfExists = cmdShim.ifExists
, asyncMap = require("slide").asyncMap
- , output = require("./utils/output.js")
module.exports = build
build.usage = "npm build <folder>\n(this is plumbing)"
@@ -150,7 +149,8 @@ function linkBins (pkg, folder, parent, gtop, cb) {
, out = npm.config.get("parseable")
? dest + "::" + src + ":BINFILE"
: dest + " -> " + src
- output.write(out, cb)
+ console.log(out)
+ cb()
})
})
}, cb)
diff --git a/lib/cache.js b/lib/cache.js
index 899867d5b..2ca1215b9 100644
--- a/lib/cache.js
+++ b/lib/cache.js
@@ -67,7 +67,6 @@ var mkdir = require("mkdirp")
, registry = npm.registry
, log = require("npmlog")
, path = require("path")
- , output
, sha = require("./utils/sha.js")
, asyncMap = require("slide").asyncMap
, semver = require("semver")
@@ -145,7 +144,6 @@ function read (name, ver, forceBypass, cb) {
// npm cache ls [<path>]
function ls (args, cb) {
- output = output || require("./utils/output.js")
args = args.join("/").split("@").join("/")
if (args.substr(-1) === "/") args = args.substr(0, args.length - 1)
var prefix = npm.config.get("cache")
@@ -153,11 +151,10 @@ function ls (args, cb) {
prefix = "~" + prefix.substr(process.env.HOME.length)
}
ls_(args, npm.config.get("depth"), function(er, files) {
- output.write(files.map(function (f) {
+ console.log(files.map(function (f) {
return path.join(prefix, f)
- }).join("\n").trim(), function (er) {
- return cb(er, files)
- })
+ }).join("\n").trim())
+ cb(er, files)
})
}
diff --git a/lib/completion.js b/lib/completion.js
index ebee00387..697f2d166 100644
--- a/lib/completion.js
+++ b/lib/completion.js
@@ -5,8 +5,7 @@ completion.usage = "npm completion >> ~/.bashrc\n"
+ "npm completion >> ~/.zshrc\n"
+ "source <(npm completion)"
-var output = require("./utils/output.js")
- , configDefs = require("./utils/config-defs.js")
+var configDefs = require("./utils/config-defs.js")
, configTypes = configDefs.types
, shorthands = configDefs.shorthands
, nopt = require("nopt")
@@ -200,7 +199,9 @@ function wrapCb (cb, opts) { return function (er, compls) {
})
console.error([er && er.stack, compls, opts.partialWord])
if (er || compls.length === 0) return cb(er)
- output.write(compls.join("\n"), 1, false, cb)
+
+ console.log(compls.join("\n"))
+ cb()
}}
// the current word has a dash. Return the config names,
diff --git a/lib/config.js b/lib/config.js
index 67f2b3547..870f05f42 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -15,7 +15,6 @@ var ini = require("./utils/ini.js")
, exec = require("./utils/exec.js")
, fs = require("graceful-fs")
, dc
- , output = require("./utils/output.js")
, types = require("./utils/config-defs.js").types
config.completion = function (opts, cb) {
@@ -140,7 +139,8 @@ function get (key, cb) {
if (key.charAt(0) === "_") {
return cb(new Error("---sekretz---"))
}
- output.write(npm.config.get(key), cb)
+ console.log(npm.config.get(key))
+ cb()
}
function sort (a, b) {
@@ -273,7 +273,8 @@ function list (cb) {
+ "; HOME = " + process.env.HOME + eol
+ "; 'npm config ls -l' to show all defaults." + eol
- return output.write(msg, cb)
+ console.log(msg)
+ cb()
}
var defaults = ini.defaultConfig
@@ -290,7 +291,8 @@ function list (cb) {
})
msg += eol
- return output.write(msg, cb)
+ console.log(msg)
+ cb()
}
function unknown (action, cb) {
diff --git a/lib/help-search.js b/lib/help-search.js
index 6f1f117cb..76fede11f 100644
--- a/lib/help-search.js
+++ b/lib/help-search.js
@@ -2,7 +2,6 @@
module.exports = helpSearch
var fs = require("graceful-fs")
- , output = require("./utils/output.js")
, path = require("path")
, asyncMap = require("slide").asyncMap
, cliDocsPath = path.join(__dirname, "..", "doc", "cli")
@@ -118,8 +117,8 @@ function helpSearch (args, silent, cb) {
}
if (results.length === 0) {
- return output.write("No results for "
- + args.map(JSON.stringify).join(" "), cb)
+ console.log("No results for " + args.map(JSON.stringify).join(" "))
+ return cb()
}
// sort results by number of results found, then by number of hits
@@ -164,8 +163,15 @@ function helpSearch (args, silent, cb) {
})
out = newOut.join("")
}
- out = out.split("\1").join("\033[31;40m")
- .split("\2").join("\033[0m")
+ if (npm.config.get("color")) {
+ var color = "\033[31;40m"
+ , reset = "\033[0m"
+ } else {
+ var color = ""
+ , reset = ""
+ }
+ out = out.split("\1").join(color)
+ .split("\2").join(reset)
return out
}).join("\n").trim()
return out
@@ -179,7 +185,8 @@ function helpSearch (args, silent, cb) {
+ "(run with -l or --long to see more context)"
}
- output.write(out.trim(), function (er) { cb(er, results) })
+ console.log(out.trim())
+ cb(null, results)
})
})
diff --git a/lib/help.js b/lib/help.js
index 998d90471..495db8381 100644
--- a/lib/help.js
+++ b/lib/help.js
@@ -12,7 +12,6 @@ var fs = require("graceful-fs")
, path = require("path")
, exec = require("./utils/exec.js")
, npm = require("./npm.js")
- , output = require("./utils/output.js")
, log = require("npmlog")
function help (args, cb) {
@@ -35,7 +34,8 @@ function help (args, cb) {
) {
npm.config.set("loglevel", "silent")
log.level = "silent"
- return output.write(npm.commands[section].usage, cb)
+ console.log(npm.commands[section].usage)
+ return cb()
}
var sectionPath = path.join( __dirname, "..", "man", "man" + num
@@ -67,7 +67,8 @@ function help (args, cb) {
if (!b) {
return cb(new Error("viewer=browser and no browser set."))
}
- output.write("Opening HTML in default browser...", cb)
+ console.log("Opening HTML in default browser...")
+ process.nextTick(cb)
// windows is SO weird.
if (process.platform === "win32") {
exec("cmd", ["/c", htmlPath], env, false, function () {})
@@ -85,7 +86,7 @@ function help (args, cb) {
if (er) return cb(er)
npm.config.set("loglevel", "silent")
log.level = "silent"
- output.write
+ console.log
( ["\nUsage: npm <command>"
, ""
, "where <command> is one of:"
@@ -104,7 +105,8 @@ function help (args, cb) {
, "Config info can be viewed via: npm help config"
, ""
, "npm@" + npm.version + " " + path.dirname(__dirname)
- ].join("\n"), function () { cb(er) })
+ ].join("\n"))
+ cb(er)
})
}
diff --git a/lib/install.js b/lib/install.js
index e64766bbe..28a04ddd4 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -64,7 +64,6 @@ var npm = require("./npm.js")
, cache = require("./cache.js")
, asyncMap = require("slide").asyncMap
, chain = require("slide").chain
- , output
, url = require("url")
, mkdir = require("mkdirp")
, lifecycle = require("./utils/lifecycle.js")
@@ -75,18 +74,12 @@ function install (args, cb_) {
function cb (er, installed) {
if (er) return cb_(er)
- output = output || require("./utils/output.js")
-
var tree = treeify(installed)
, pretty = prettify(tree, installed).trim()
- if (pretty) output.write(pretty, afterWrite)
- else afterWrite()
-
- function afterWrite (er) {
- if (er) return cb_(er)
- save(where, installed, tree, pretty, cb_)
- }
+ if (pretty) console.log(pretty)
+ if (er) return cb_(er)
+ save(where, installed, tree, pretty, cb_)
}
// the /path/to/node_modules/..
diff --git a/lib/link.js b/lib/link.js
index 1e9997497..e9127960c 100644
--- a/lib/link.js
+++ b/lib/link.js
@@ -9,7 +9,6 @@ var npm = require("./npm.js")
, chain = require("slide").chain
, path = require("path")
, rm = require("rimraf")
- , output = require("./utils/output.js")
, build = require("./build.js")
module.exports = link
@@ -153,8 +152,8 @@ function resultPrinter (pkg, src, dest, rp, cb) {
return parseableOutput(dest, rp || src, cb)
}
if (rp === src) rp = null
- output.write(where+" -> " + src
- +(rp ? " -> " + rp: ""), cb)
+ console.log(where + " -> " + src + (rp ? " -> " + rp: ""))
+ cb()
}
function parseableOutput (dest, rp, cb) {
@@ -165,5 +164,6 @@ function parseableOutput (dest, rp, cb) {
// *just* print the target folder.
// However, we don't actually ever read the version number, so
// the second field is always blank.
- output.write(dest + "::" + rp, cb)
+ console.log(dest + "::" + rp)
+ cb()
}
diff --git a/lib/ls.js b/lib/ls.js
index 2b45ca3dc..9d385ca52 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -9,7 +9,6 @@ module.exports = exports = ls
var npm = require("./npm.js")
, readInstalled = require("read-installed")
- , output = require("./utils/output.js")
, log = require("npmlog")
, path = require("path")
, archy = require("archy")
@@ -58,7 +57,8 @@ function ls (args, silent, cb) {
} else if (data) {
out = makeArchy(bfs, long, dir)
}
- output.write(out, function (er) { cb(er, data, lite) })
+ console.log(out)
+ cb(null, data, lite)
})
}
@@ -205,12 +205,17 @@ function makeArchy (data, long, dir) {
}
function makeArchy_ (data, long, dir, depth, parent, d) {
+ var color = npm.config.get("color")
if (typeof data === "string") {
if (depth < npm.config.get("depth")) {
// just missing
var p = parent.link || parent.path
log.warn("unmet dependency", "%s in %s", d+" "+data, p)
- data = "\033[31;40mUNMET DEPENDENCY\033[0m " + d + " " + data
+ var unmet = "UNMET DEPENDENCY"
+ if (color) {
+ unmet = "\033[31;40m" + unmet + "\033[0m"
+ }
+ data = unmet + " " + d + " " + data
} else {
data = d+"@"+ data +" (max depth reached)"
}
@@ -221,17 +226,23 @@ function makeArchy_ (data, long, dir, depth, parent, d) {
// the top level is a bit special.
out.label = data._id || ""
if (data._found === true && data._id) {
- out.label = "\033[33;40m" + out.label.trim() + "\033[m "
+ var pre = color ? "\033[33;40m" : ""
+ , post = color ? "\033[m" : ""
+ out.label = pre + out.label.trim() + post + " "
}
if (data.link) out.label += " -> " + data.link
if (data.invalid) {
if (data.realName !== data.name) out.label += " ("+data.realName+")"
- out.label += " \033[31;40minvalid\033[0m"
+ out.label += " " + (color ? "\033[31;40m" : "")
+ + "invalid"
+ + (color ? "\033[0m" : "")
}
if (data.extraneous && data.path !== dir) {
- out.label += " \033[32;40mextraneous\033[0m"
+ out.label += " " + (color ? "\033[32;40m" : "")
+ + "extraneous"
+ + (color ? "\033[0m" : "")
}
if (long) {
diff --git a/lib/outdated.js b/lib/outdated.js
index 23f655298..0c9c66952 100644
--- a/lib/outdated.js
+++ b/lib/outdated.js
@@ -30,11 +30,10 @@ function outdated (args, silent, cb) {
if (typeof cb !== "function") cb = silent, silent = false
var dir = path.resolve(npm.dir, "..")
outdated_(args, dir, {}, function (er, list) {
- function cb_ (er) { if (typeof cb === "function") cb(er, list) }
-
- if (er || silent) return cb_(er)
+ if (er || silent) return cb(er)
var outList = list.map(makePretty)
- require("./utils/output.js").write(outList.join("\n"), cb_)
+ console.log(outList.join("\n"))
+ cb(null, list)
})
}
diff --git a/lib/owner.js b/lib/owner.js
index a7cc5bdac..16008b538 100644
--- a/lib/owner.js
+++ b/lib/owner.js
@@ -67,7 +67,6 @@ owner.completion = function (opts, cb) {
var npm = require("./npm.js")
, registry = npm.registry
, log = require("npmlog")
- , output
, readJson = require("read-package-json")
function owner (args, cb) {
@@ -91,8 +90,8 @@ function ls (pkg, cb) {
var owners = data.maintainers
if (!owners || !owners.length) msg = "admin party!"
else msg = owners.map(function (o) { return o.name +" <"+o.email+">" }).join("\n")
- output = output || require("./utils/output.js")
- output.write(msg, function (er) { cb(er, owners) })
+ console.log(msg)
+ cb(er, owners)
})
}
diff --git a/lib/pack.js b/lib/pack.js
index 1e3bd0c56..302aa81f2 100644
--- a/lib/pack.js
+++ b/lib/pack.js
@@ -7,7 +7,6 @@ module.exports = pack
var npm = require("./npm.js")
, install = require("./install.js")
, cache = require("./cache.js")
- , output = require("./utils/output.js")
, fs = require("graceful-fs")
, chain = require("slide").chain
, path = require("path")
@@ -35,7 +34,8 @@ function printFiles (files, cb) {
files = files.map(function (file) {
return path.relative(cwd, file)
})
- output.write(files.join("\n"), cb)
+ console.log(files.join("\n"))
+ cb()
}
// add to cache, then cp to the cwd
diff --git a/lib/prefix.js b/lib/prefix.js
index f37aacf2c..e002edea1 100644
--- a/lib/prefix.js
+++ b/lib/prefix.js
@@ -1,10 +1,11 @@
module.exports = prefix
var npm = require("./npm.js")
- , output = require("./utils/output.js")
prefix.usage = "npm prefix\nnpm prefix -g\n(just prints the prefix folder)"
-function prefix (args, cb) {
- output.write(npm.prefix, function (er) { cb(er, npm.prefix) })
+function prefix (args, silent, cb) {
+ if (typeof cb !== "function") cb = silent, silent = false
+ if (!silent) console.log(npm.prefix)
+ process.nextTick(cb.bind(this, null, npm.prefix))
}
diff --git a/lib/publish.js b/lib/publish.js
index 348862dbb..fd22b8e60 100644
--- a/lib/publish.js
+++ b/lib/publish.js
@@ -10,7 +10,6 @@ var npm = require("./npm.js")
, fs = require("graceful-fs")
, lifecycle = require("./utils/lifecycle.js")
, chain = require("slide").chain
- , output = require("./utils/output.js")
publish.usage = "npm publish <tarball>"
+ "\nnpm publish <folder>"
@@ -98,7 +97,8 @@ function regPublish (data, isRetry, arg, cachedir, cb) {
})
}
if (er) return cb(er)
- output.write("+ " + data._id, cb)
+ console.log("+ " + data._id)
+ cb()
})
})
}
diff --git a/lib/rebuild.js b/lib/rebuild.js
index c9f623d6c..16451fbbb 100644
--- a/lib/rebuild.js
+++ b/lib/rebuild.js
@@ -6,7 +6,6 @@ var readInstalled = require("read-installed")
, log = require("npmlog")
, path = require("path")
, npm = require("./npm.js")
- , output = require("./utils/output.js")
, asyncMap = require("slide").asyncMap
, fs = require("graceful-fs")
, exec = require("./utils/exec.js")
@@ -51,9 +50,10 @@ function cleanBuild (folders, set, cb) {
if (er) return cb(er)
npm.commands.build(folders, function (er) {
if (er) return cb(er)
- output.write(folders.map(function (f) {
+ console.log(folders.map(function (f) {
return set[f] + " " + f
- }).join("\n"), cb)
+ }).join("\n"))
+ cb()
})
})
}
diff --git a/lib/root.js b/lib/root.js
index 59ccc0b08..409b20b78 100644
--- a/lib/root.js
+++ b/lib/root.js
@@ -1,10 +1,11 @@
module.exports = root
var npm = require("./npm.js")
- , output = require("./utils/output.js")
root.usage = "npm root\nnpm root -g\n(just prints the root folder)"
-function root (args, cb) {
- output.write(npm.dir, function (er) { cb(er, npm.dir) })
+function root (args, silent, cb) {
+ if (typeof cb !== "function") cb = silent, silent = false
+ if (!silent) console.log(npm.dir)
+ process.nextTic(cb.bind(this, null, npm.dir))
}
diff --git a/lib/search.js b/lib/search.js
index 9ed712bcc..cb02bf4bd 100644
--- a/lib/search.js
+++ b/lib/search.js
@@ -4,7 +4,6 @@ module.exports = exports = search
var npm = require("./npm.js")
, registry = npm.registry
, semver = require("semver")
- , output
search.usage = "npm search [some search terms ...]"
@@ -30,9 +29,9 @@ search.completion = function (opts, cb) {
})
}
-function search (args, silent, staleness, cb_) {
- if (typeof cb_ !== "function") cb_ = staleness, staleness = 600
- if (typeof cb_ !== "function") cb_ = silent, silent = false
+function search (args, silent, staleness, cb) {
+ if (typeof cb !== "function") cb = staleness, staleness = 600
+ if (typeof cb !== "function") cb = silent, silent = false
var searchopts = npm.config.get("searchopts")
, searchexclude = npm.config.get("searchexclude")
@@ -51,10 +50,9 @@ function search (args, silent, staleness, cb_) {
// now data is the list of data that we want to show.
// prettify and print it, and then provide the raw
// data to the cb.
- if (er || silent) return cb_(er, data)
- function cb (er) { return cb_(er, data) }
- output = output || require("./utils/output.js")
- output.write(prettify(data, args), cb)
+ if (er || silent) return cb(er, data)
+ console.log(prettify(data, args))
+ cb(null, data)
})
}
@@ -255,7 +253,9 @@ function addColorMarker (str, arg, i) {
function colorize (line) {
for (var i = 0; i < cl; i ++) {
var m = i + 1
- line = line.split(String.fromCharCode(m)).join("\033["+colors[i]+"m")
+ var color = npm.config.get("color") ? "\033["+colors[i]+"m" : ""
+ line = line.split(String.fromCharCode(m)).join(color)
}
- return line.split("\u0000").join("\033[0m")
+ var uncolor = npm.config.get("color") ? "\033[0m" : ""
+ return line.split("\u0000").join(uncolor)
}
diff --git a/lib/shrinkwrap.js b/lib/shrinkwrap.js
index cdad89abc..e41f8cf63 100644
--- a/lib/shrinkwrap.js
+++ b/lib/shrinkwrap.js
@@ -4,7 +4,6 @@
module.exports = exports = shrinkwrap
var npm = require("./npm.js")
- , output = require("./utils/output.js")
, log = require("npmlog")
, fs = require("fs")
, path = require("path")
@@ -42,8 +41,7 @@ function shrinkwrap_ (pkginfo, silent, cb) {
fs.writeFile(file, swdata, function (er) {
if (er) return cb(er)
if (silent) return cb(null, pkginfo)
- output.write("wrote npm-shrinkwrap.json", function (er) {
- cb(er, pkginfo)
- })
+ console.log("wrote npm-shrinkwrap.json")
+ cb(null, pkginfo)
})
}
diff --git a/lib/star.js b/lib/star.js
index fc4fb96f1..33b12471a 100644
--- a/lib/star.js
+++ b/lib/star.js
@@ -5,7 +5,6 @@ var npm = require("./npm.js")
, registry = npm.registry
, log = require("npmlog")
, asyncMap = require("slide").asyncMap
- , output = require("./utils/output.js")
star.usage = "npm star <package> [pkg, pkg, ...]\n"
+ "npm unstar <package> [pkg, pkg, ...]"
@@ -25,7 +24,7 @@ function star (args, cb) {
asyncMap(args, function (pkg, cb) {
registry.star(pkg, using, function (er, data, raw, req) {
if (!er) {
- output.write(s + " "+pkg, npm.config.get("outfd"))
+ console.log(s + " "+pkg)
log.verbose("star", data)
}
cb(er, data, raw, req)
diff --git a/lib/submodule.js b/lib/submodule.js
index a0d215994..c1523984c 100644
--- a/lib/submodule.js
+++ b/lib/submodule.js
@@ -6,7 +6,6 @@ module.exports = submodule
var npm = require("./npm.js")
, exec = require("./utils/exec.js")
- , output = require("./utils/output.js")
, cache = require("./cache.js")
, asyncMap = require("slide").asyncMap
, chain = require("slide").chain
diff --git a/lib/unpublish.js b/lib/unpublish.js
index 9d0c955f9..def308525 100644
--- a/lib/unpublish.js
+++ b/lib/unpublish.js
@@ -6,7 +6,6 @@ var log = require("npmlog")
, registry = npm.registry
, readJson = require("read-package-json")
, path = require("path")
- , output = require("./utils/output.js")
unpublish.usage = "npm unpublish <project>[@<version>]"
@@ -67,7 +66,8 @@ function unpublish (args, cb) {
function gotProject (project, version, cb_) {
function cb (er) {
if (er) return cb_(er)
- output.write("- " + project + (version ? "@" + version : ""), cb_)
+ console.log("- " + project + (version ? "@" + version : ""))
+ cb_()
}
// remove from the cache first
diff --git a/lib/utils/lifecycle.js b/lib/utils/lifecycle.js
index 90b5002b6..7fc900884 100644
--- a/lib/utils/lifecycle.js
+++ b/lib/utils/lifecycle.js
@@ -9,7 +9,6 @@ var log = require("npmlog")
, fs = require("graceful-fs")
, chain = require("slide").chain
, constants = require("constants")
- , output = require("./output.js")
, Stream = require("stream").Stream
, PATH = "PATH"
@@ -149,32 +148,29 @@ function runPackageLifecycle (pkg, env, wd, unsafe, cb) {
var note = "\n> " + pkg._id + " " + stage + " " + wd
+ "\n> " + cmd + "\n"
- output.write(note, function (er) {
- if (er) return cb(er)
-
- exec( sh, [shFlag, cmd], env, true, wd
- , user, group
- , function (er, code, stdout, stderr) {
- if (er && !npm.ROLLBACK) {
- log.info(pkg._id, "Failed to exec "+stage+" script")
- er.message = pkg._id + " "
- + stage + ": `" + env.npm_lifecycle_script+"`\n"
- + er.message
- if (er.code !== "EPERM") {
- er.code = "ELIFECYCLE"
- }
- er.pkgid = pkg._id
- er.stage = stage
- er.script = env.npm_lifecycle_script
- er.pkgname = pkg.name
- return cb(er)
- } else if (er) {
- log.error(pkg._id+"."+stage, er)
- log.error(pkg._id+"."+stage, "continuing anyway")
- return cb()
+ console.log(note)
+ exec( sh, [shFlag, cmd], env, true, wd
+ , user, group
+ , function (er, code, stdout, stderr) {
+ if (er && !npm.ROLLBACK) {
+ log.info(pkg._id, "Failed to exec "+stage+" script")
+ er.message = pkg._id + " "
+ + stage + ": `" + env.npm_lifecycle_script+"`\n"
+ + er.message
+ if (er.code !== "EPERM") {
+ er.code = "ELIFECYCLE"
}
- cb(er)
- })
+ er.pkgid = pkg._id
+ er.stage = stage
+ er.script = env.npm_lifecycle_script
+ er.pkgname = pkg.name
+ return cb(er)
+ } else if (er) {
+ log.error(pkg._id+"."+stage, er)
+ log.error(pkg._id+"."+stage, "continuing anyway")
+ return cb()
+ }
+ cb(er)
})
}
diff --git a/lib/view.js b/lib/view.js
index e291031c1..9b34df3bf 100644
--- a/lib/view.js
+++ b/lib/view.js
@@ -44,7 +44,6 @@ var npm = require("./npm.js")
, ini = require("ini")
, log = require("npmlog")
, util = require("util")
- , output
, semver = require("semver")
function view (args, silent, cb) {
@@ -184,7 +183,6 @@ function printData (data, name, cb) {
, msg = ""
, showVersions = versions.length > 1
, showFields
- function cb_ (er) { return cb(er, data) }
versions.forEach(function (v, i) {
var fields = Object.keys(data[v])
@@ -200,8 +198,9 @@ function printData (data, name, cb) {
+ (showFields ? f : "") + d + "\n"
})
})
- output = output || require("./utils/output.js")
- output.write(msg, cb_)
+
+ console.log(msg)
+ cb(null, data)
}
function cleanup (data) {
if (Array.isArray(data)) {
diff --git a/lib/whoami.js b/lib/whoami.js
index b6e495253..664cbdbb0 100644
--- a/lib/whoami.js
+++ b/lib/whoami.js
@@ -1,12 +1,13 @@
module.exports = whoami
var npm = require("./npm.js")
- , output = require("./utils/output.js")
whoami.usage = "npm whoami\n(just prints the 'username' config)"
-function whoami (args, cb) {
+function whoami (args, silent, cb) {
+ if (typeof cb !== "function") cb = silent, silent = false
var me = npm.config.get("username")
- if (!me) me = "Not authed. Run 'npm adduser'"
- output.write(me, cb)
+ msg = me ? me : "Not authed. Run 'npm adduser'"
+ if (!silent) console.log(msg)
+ process.nextTick(cb.bind(this, null, me))
}