diff options
author | isaacs <i@izs.me> | 2010-10-29 05:34:34 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-10-29 05:34:34 +0400 |
commit | af9302894ee1eabfaff8cdc1424c215c45b48a0a (patch) | |
tree | 97d7a8962dfc06d98c2770c65f1387e8bb542556 /lib/owner.js | |
parent | ed004e0817334c58d7a56fd0bbdeca048783f29b (diff) |
refactor output to go through central module
This is the dramatic refactor which was alluded to in ed004e0.
1. All output goes through a central module.
2. Callbacks are called when data is flushed, but only ever called once
3. Set "outfd" and "logfd" to direct output and error to different places,
or set to a writable stream when using npm programmatically.
4. Clean up the many varied ways to write data to the console.
5. Set colors smarter, and allow overriding by setting the "color" config.
Diffstat (limited to 'lib/owner.js')
-rw-r--r-- | lib/owner.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/owner.js b/lib/owner.js index 38eee99c6..7fb7d6c36 100644 --- a/lib/owner.js +++ b/lib/owner.js @@ -9,6 +9,8 @@ var registry = require("./utils/registry") , get = registry.request.GET , put = registry.request.PUT , log = require("./utils/log") + , output = require("./utils/output") + , npm = require("../npm") function owner (args, cb) { var action = args.shift() @@ -23,11 +25,14 @@ function owner (args, cb) { function ls (pkg, cb) { if (!pkg) return cb(owner.usage) get(pkg, function (er, data) { + var msg = "" if (er) return log.er(cb, "Couldn't get owner data for "+pkg)(er) var owners = data.maintainers - if (!owners || !owners.length) console.log("admin party!") - else owners.forEach(function (o) { console.log(o.name +" <"+o.email+">") }) - cb() + if (!owners || !owners.length) msg = "admin party!" + else msg = owners.map(function (o) { return o.name +" <"+o.email+">") }).join("\n") + output.write(npm.config.get("outfd"), msg, function (er) { + cb(er, owners) + }) }) } |