@@ -14,33 +14,31 @@ export class Prompter implements IPrompter {
14
14
}
15
15
}
16
16
17
- public async get ( schemas : IPromptSchema [ ] ) : Promise < any > {
17
+ public async get ( questions : prompt . Question [ ] ) : Promise < any > {
18
18
let promptResult : any ;
19
19
20
20
try {
21
21
promptResult = await new Promise < any > ( ( resolve , reject ) => {
22
22
this . muteStdout ( ) ;
23
23
24
24
if ( ! helpers . isInteractive ( ) ) {
25
- if ( _ . some ( schemas , s => ! s . default ) ) {
25
+ if ( _ . some ( questions , s => ! s . default ) ) {
26
26
reject ( new Error ( "Console is not interactive and no default action specified." ) ) ;
27
27
} else {
28
28
const result : any = { } ;
29
29
30
- _ . each ( schemas , s => {
30
+ _ . each ( questions , s => {
31
31
// Curly brackets needed because s.default() may return false and break the loop
32
32
result [ s . name ] = s . default ( ) ;
33
33
} ) ;
34
34
35
35
resolve ( result ) ;
36
36
}
37
37
} else {
38
- prompt . prompt ( schemas , ( result : any ) => {
39
- if ( result ) {
38
+ prompt . prompt ( questions ) . then ( ( result : any ) => {
40
39
resolve ( result ) ;
41
- } else {
42
- reject ( new Error ( `Unable to get result from prompt: ${ result } ` ) ) ;
43
- }
40
+ } , ( error ) => {
41
+ reject ( new Error ( `Unable to get result from prompt: ${ error } ` ) ) ;
44
42
} ) ;
45
43
}
46
44
} ) ;
@@ -52,7 +50,7 @@ export class Prompter implements IPrompter {
52
50
}
53
51
54
52
public async getPassword ( prompt : string , options ?: IAllowEmpty ) : Promise < string > {
55
- const schema : IPromptSchema = {
53
+ const schema : prompt . Question = {
56
54
message : prompt ,
57
55
type : "password" ,
58
56
name : "password" ,
@@ -67,7 +65,7 @@ export class Prompter implements IPrompter {
67
65
}
68
66
69
67
public async getString ( prompt : string , options ?: IPrompterOptions ) : Promise < string > {
70
- const schema : IPromptSchema = {
68
+ const schema : prompt . Question = {
71
69
message : prompt ,
72
70
type : "input" ,
73
71
name : "inputString" ,
@@ -83,7 +81,7 @@ export class Prompter implements IPrompter {
83
81
}
84
82
85
83
public async promptForChoice ( promptMessage : string , choices : any [ ] ) : Promise < string > {
86
- const schema : IPromptSchema = {
84
+ const schema : prompt . Question = {
87
85
message : promptMessage ,
88
86
type : "list" ,
89
87
name : "userAnswer" ,
0 commit comments