@@ -14,45 +14,34 @@ export class Prompter implements IPrompter {
1414 }
1515 }
1616
17- public async get ( schemas : IPromptSchema [ ] ) : Promise < any > {
18- let promptResult : any ;
19-
17+ public async get ( questions : prompt . Question [ ] ) : Promise < any > {
2018 try {
21- promptResult = await new Promise < any > ( ( resolve , reject ) => {
2219 this . muteStdout ( ) ;
2320
2421 if ( ! helpers . isInteractive ( ) ) {
25- if ( _ . some ( schemas , s => ! s . default ) ) {
26- reject ( new Error ( "Console is not interactive and no default action specified." ) ) ;
22+ if ( _ . some ( questions , s => ! s . default ) ) {
23+ throw new Error ( "Console is not interactive and no default action specified." ) ;
2724 } else {
2825 const result : any = { } ;
2926
30- _ . each ( schemas , s => {
27+ _ . each ( questions , s => {
3128 // Curly brackets needed because s.default() may return false and break the loop
3229 result [ s . name ] = s . default ( ) ;
3330 } ) ;
3431
35- resolve ( result ) ;
32+ return result ;
3633 }
3734 } else {
38- prompt . prompt ( schemas , ( result : any ) => {
39- if ( result ) {
40- resolve ( result ) ;
41- } else {
42- reject ( new Error ( `Unable to get result from prompt: ${ result } ` ) ) ;
43- }
44- } ) ;
35+ const result = await prompt . prompt ( questions ) ;
36+ return result ;
4537 }
46- } ) ;
4738 } finally {
4839 this . unmuteStdout ( ) ;
4940 }
50-
51- return promptResult ;
5241 }
5342
5443 public async getPassword ( prompt : string , options ?: IAllowEmpty ) : Promise < string > {
55- const schema : IPromptSchema = {
44+ const schema : prompt . Question = {
5645 message : prompt ,
5746 type : "password" ,
5847 name : "password" ,
@@ -67,7 +56,7 @@ export class Prompter implements IPrompter {
6756 }
6857
6958 public async getString ( prompt : string , options ?: IPrompterOptions ) : Promise < string > {
70- const schema : IPromptSchema = {
59+ const schema : prompt . Question = {
7160 message : prompt ,
7261 type : "input" ,
7362 name : "inputString" ,
@@ -83,7 +72,7 @@ export class Prompter implements IPrompter {
8372 }
8473
8574 public async promptForChoice ( promptMessage : string , choices : any [ ] ) : Promise < string > {
86- const schema : IPromptSchema = {
75+ const schema : prompt . Question = {
8776 message : promptMessage ,
8877 type : "list" ,
8978 name : "userAnswer" ,
0 commit comments