File tree Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Expand file tree Collapse file tree 2 files changed +12
-15
lines changed Original file line number Diff line number Diff line change 11import { prompt } from 'gluegun' ;
22import { PromptOptions } from 'gluegun/build/types/toolbox/prompt-enquirer-types' ;
33
4- interface PromptStep {
5- execute : ( ) => Promise < any > ;
6- }
7-
84export class PromptManager {
9- private steps : PromptStep [ ] = [ ] ;
5+ private steps : PromptOptions [ ] = [ ] ;
106 private currentStep = 0 ;
117 private results : any [ ] = [ ] ;
128
139 addStep ( options : PromptOptions ) {
14- this . steps . push ( {
15- execute : async ( ) => {
16- const result = await prompt . ask ( options ) ;
17- return result ;
18- } ,
19- } ) ;
10+ this . steps . push ( options ) ;
11+ }
12+
13+ // runs all steps and returns the results
14+ async execute ( ) {
15+ return prompt . ask ( this . steps ) ;
2016 }
2117
22- async executePrompts ( ) {
18+ // allows going back with Escape and returns the results
19+ async executeInteractive ( ) {
2320 let isCtrlC = false ;
2421 // gluegun always throws empty string, so we have this workaround
2522 const keypressHandler = ( _ : string , key : { name : string ; ctrl : boolean } ) => {
@@ -31,7 +28,7 @@ export class PromptManager {
3128
3229 while ( this . currentStep < this . steps . length ) {
3330 try {
34- const result = await this . steps [ this . currentStep ] . execute ( ) ;
31+ const result = await prompt . ask ( this . steps [ this . currentStep ] ) ;
3532 this . results [ this . currentStep ] = result ;
3633 this . currentStep ++ ;
3734 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -742,8 +742,7 @@ async function processInitForm(
742742 } ,
743743 } ) ;
744744
745- // Execute all prompts with ESC navigation support
746- const results = await promptManager . executePrompts ( ) ;
745+ const results = await promptManager . executeInteractive ( ) ;
747746 console . log ( 'results' , results ) ;
748747
749748 return {
@@ -762,6 +761,7 @@ async function processInitForm(
762761 cleanup : spkgCleanup ,
763762 } ;
764763 } catch ( e ) {
764+ console . error ( e ) ;
765765 this . error ( e , { exit : 1 } ) ;
766766 }
767767}
You can’t perform that action at this time.
0 commit comments