Skip to content

Commit

Permalink
feat: prompter.confirm can require a positive answer(#157)
Browse files Browse the repository at this point in the history
* refactor: move confirm to Prompter so it can be on Ux export

* feat: prompter.confirm can require a positive answer

* feat: default option for confirm
  • Loading branch information
mshanemc committed Dec 7, 2022
1 parent 2c7aa1a commit 05571a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
"publishConfig": {
"access": "public"
}
}
}
4 changes: 3 additions & 1 deletion src/ux/prompter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ export class Prompter {
*
* @param message text to display. Do not include a question mark.
* @param ms milliseconds to wait for user input. Defaults to 10s.
* @param defaultAnswer default answer for the prompt. Defaults to true. Pass in `false` to require a positive response.
* @return true if the user confirms, false if they do not.
*/
public async confirm(message: string, ms = 10000): Promise<boolean> {
public async confirm(message: string, ms = 10000, defaultAnswer = true): Promise<boolean> {
const { confirmed } = await this.timedPrompt<{ confirmed: boolean }>(
[
{
name: 'confirmed',
message,
type: 'confirm',
default: defaultAnswer,
},
],
ms
Expand Down

0 comments on commit 05571a0

Please sign in to comment.