@@ -141,10 +141,7 @@ const pkg = loadJsonFileSync(path.join(__dirname, '../', 'package.json'));
141141 } else if ( whichBumpType . includes ( 'beta' ) ) {
142142 publishTagName = 'beta' ;
143143 }
144- let otp = '' ;
145- if ( await promptConfirmation ( `${ c . bgMagenta ( dryRunPrefix ) } Do you have OTP (One-Time-Password) enabled?` , undefined , 1 ) ) {
146- otp = await promptOtp ( ) ;
147- }
144+ const otp = await promptOtp ( dryRunPrefix ) ;
148145 await publishPackage ( publishTagName , { cwd, otp, dryRun : argv . dryRun } ) ;
149146 console . log ( `${ c . bgMagenta ( dryRunPrefix ) } 📦 Published to NPM - 🔗 https://www.npmjs.com/package/${ pkg . name } ` . trim ( ) )
150147 }
@@ -280,18 +277,20 @@ async function promptConfirmation(message, choices, defaultIndex) {
280277 }
281278
282279 // get and process input
283- const input = await getConsoleInput ( `Enter value (default ${ ( defaultIndex + 1 ) } ) ` ) ;
280+ const input = await getConsoleInput ( `Enter value (default ${ ( defaultIndex + 1 ) } ): ` ) ;
284281 var index = ! isNaN ( input ) && ! isNaN ( parseFloat ( input ) ) ? + input - 1 : defaultIndex ;
285282 if ( index < 0 || index >= choices . length ) {
286283 throw Error ( `The input ${ input } could not be matched to a selection` ) ;
287284 }
288285 return choices [ index ] . value ;
289286}
290287
291- async function promptOtp ( ) {
292- const otp = await getConsoleInput ( `Enter OTP value:` ) ;
293- if ( otp . length < 6 ) {
294- throw new Error ( 'OTP must be 6 digits.' ) ;
288+ async function promptOtp ( dryRunPrefix = '' ) {
289+ const otp = await getConsoleInput ( `${ c . bgMagenta ( dryRunPrefix ) } If you have an OTP (One-Time-Password), type it now or press "Enter" to continue: \n` ) ;
290+ if ( ! otp ) {
291+ console . log ( 'No OTP provided, continuing to next step...' )
292+ } else if ( otp . length > 0 && otp . length < 6 ) {
293+ throw new Error ( 'OTP must be 6 exactly digits.' ) ;
295294 }
296295 return otp ;
297296}
0 commit comments