import prompts from 'prompts' ; param prompt param maxDepth param cancelPrompt export const requiredPrompts = ( prompt , maxDepth = 2 , cancelPrompt = '\nAnswering this prompt is required to continue.\n' , depth = 0 ) : Promise < prompts . Answers < string > > => new Promise ( ( res ) => { if ( depth > 0 && depth < maxDepth ) process . stdout . write ( cancelPrompt ) ; if ( depth >= maxDepth ) { console . log ( `\nRequired prompt cancelled ${ maxDepth } times! Exiting...` ) ; process . exit ( ) ; } prompts ( prompt , { onCancel : ( ) => res ( requiredPrompts ( prompt , maxDepth , cancelPrompt , ( depth += 1 ) ) ) } ) . then ( res ) ; } ) ;