Permalink
Browse files

Fix reading of default parameters in `npm owner`

Not `return`ing `readLocalPkg` caused callaback to be called more than
once.

Also add a default parameter to `npm owner ls` (current package).
  • Loading branch information...
1 parent 7cc468d commit 62075e84b9e666f73f2bcab2b915353ab4d37b44 @mmalecki mmalecki committed with isaacs Aug 2, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/owner.js
View
@@ -80,7 +80,12 @@ function owner (args, cb) {
}
function ls (pkg, cb) {
- if (!pkg) return cb(owner.usage)
+ if (!pkg) return readLocalPkg(function (er, pkg) {
+ if (er) return cb(er)
+ if (!pkg) return cb(owner.usage)
+ ls(pkg, cb)
+ })
+
registry.get(pkg, function (er, data) {
var msg = ""
if (er) {
@@ -96,7 +101,8 @@ function ls (pkg, cb) {
}
function add (user, pkg, cb) {
- if (!pkg) readLocalPkg(function (er, pkg) {
+ if (!user) return cb(owner.usage)
+ if (!pkg) return readLocalPkg(function (er, pkg) {
if (er) return cb(er)
if (!pkg) return cb(new Error(owner.usage))
add(user, pkg, cb)
@@ -119,7 +125,7 @@ function add (user, pkg, cb) {
}
function rm (user, pkg, cb) {
- if (!pkg) readLocalPkg(function (er, pkg) {
+ if (!pkg) return readLocalPkg(function (er, pkg) {
if (er) return cb(er)
if (!pkg) return cb(new Error(owner.usage))
rm(user, pkg, cb)

0 comments on commit 62075e8

Please sign in to comment.