summaryrefslogtreecommitdiff
path: root/deps/npm/lib/adduser.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/adduser.js')
-rw-r--r--deps/npm/lib/adduser.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/deps/npm/lib/adduser.js b/deps/npm/lib/adduser.js
index 739f14243f..94a119683a 100644
--- a/deps/npm/lib/adduser.js
+++ b/deps/npm/lib/adduser.js
@@ -66,15 +66,24 @@ function readUsername (c, u, cb) {
function readPassword (c, u, cb) {
var v = userValidate.pw
- if (!c.changed) {
- u.p = c.p
- return cb()
+ var prompt
+ if (c.p && !c.changed) {
+ prompt = "Password: (or leave unchanged) "
+ } else {
+ prompt = "Password: "
}
- read({prompt: "Password: ", silent: true}, function (er, pw) {
+
+ read({prompt: prompt, silent: true}, function (er, pw) {
if (er) {
return cb(er.message === "cancelled" ? er.message : er)
}
+ if (!c.changed && pw === "") {
+ // when the username was not changed,
+ // empty response means "use the old value"
+ pw = c.p
+ }
+
if (!pw) {
return readPassword(c, u, cb)
}
@@ -85,6 +94,7 @@ function readPassword (c, u, cb) {
return readPassword(c, u, cb)
}
+ c.changed = c.changed || c.p != pw
u.p = pw
cb(er)
})