File tree Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -336,17 +336,7 @@ export abstract class SfCommand<T> extends Command {
336336 * @return true if the user confirms, false if they do not.
337337 */
338338 public async confirm ( message : string , ms = 10000 ) : Promise < boolean > {
339- const { confirmed } = await this . timedPrompt < { confirmed : boolean } > (
340- [
341- {
342- name : 'confirmed' ,
343- message,
344- type : 'confirm' ,
345- } ,
346- ] ,
347- ms
348- ) ;
349- return confirmed ;
339+ return this . prompter . confirm ( message , ms ) ;
350340 }
351341
352342 /**
Original file line number Diff line number Diff line change @@ -49,6 +49,27 @@ export class Prompter {
4949 return result as T ;
5050 } ) ;
5151 }
52+
53+ /**
54+ * Simplified prompt for single-question confirmation. Times out and throws after 10s
55+ *
56+ * @param message text to display. Do not include a question mark.
57+ * @param ms milliseconds to wait for user input. Defaults to 10s.
58+ * @return true if the user confirms, false if they do not.
59+ */
60+ public async confirm ( message : string , ms = 10000 ) : Promise < boolean > {
61+ const { confirmed } = await this . timedPrompt < { confirmed : boolean } > (
62+ [
63+ {
64+ name : 'confirmed' ,
65+ message,
66+ type : 'confirm' ,
67+ } ,
68+ ] ,
69+ ms
70+ ) ;
71+ return confirmed ;
72+ }
5273}
5374
5475export namespace Prompter {
You can’t perform that action at this time.
0 commit comments