1
- const { promisify } = require ( 'util' )
2
- const readAsync = promisify ( require ( 'read' ) )
1
+ const read = require ( 'read' )
3
2
const userValidate = require ( 'npm-user-validate' )
4
3
const log = require ( './log-shim.js' )
5
4
@@ -17,17 +16,17 @@ const passwordPrompt = 'npm password: '
17
16
const usernamePrompt = 'npm username: '
18
17
const emailPrompt = 'email (this IS public): '
19
18
20
- function read ( opts ) {
19
+ function readWithProgress ( opts ) {
21
20
log . clearProgress ( )
22
- return readAsync ( opts ) . finally ( ( ) => log . showProgress ( ) )
21
+ return read ( opts ) . finally ( ( ) => log . showProgress ( ) )
23
22
}
24
23
25
24
function readOTP ( msg = otpPrompt , otp , isRetry ) {
26
25
if ( isRetry && otp && / ^ [ \d ] + $ | ^ [ A - F a - f 0 - 9 ] { 64 , 64 } $ / . test ( otp ) ) {
27
26
return otp . replace ( / \s + / g, '' )
28
27
}
29
28
30
- return read ( { prompt : msg , default : otp || '' } )
29
+ return readWithProgress ( { prompt : msg , default : otp || '' } )
31
30
. then ( ( rOtp ) => readOTP ( msg , rOtp , true ) )
32
31
}
33
32
@@ -36,7 +35,7 @@ function readPassword (msg = passwordPrompt, password, isRetry) {
36
35
return password
37
36
}
38
37
39
- return read ( { prompt : msg , silent : true , default : password || '' } )
38
+ return readWithProgress ( { prompt : msg , silent : true , default : password || '' } )
40
39
. then ( ( rPassword ) => readPassword ( msg , rPassword , true ) )
41
40
}
42
41
@@ -50,7 +49,7 @@ function readUsername (msg = usernamePrompt, username, isRetry) {
50
49
}
51
50
}
52
51
53
- return read ( { prompt : msg , default : username || '' } )
52
+ return readWithProgress ( { prompt : msg , default : username || '' } )
54
53
. then ( ( rUsername ) => readUsername ( msg , rUsername , true ) )
55
54
}
56
55
@@ -64,6 +63,6 @@ function readEmail (msg = emailPrompt, email, isRetry) {
64
63
}
65
64
}
66
65
67
- return read ( { prompt : msg , default : email || '' } )
66
+ return readWithProgress ( { prompt : msg , default : email || '' } )
68
67
. then ( ( username ) => readEmail ( msg , username , true ) )
69
68
}
0 commit comments