Skip to content

Commit 88ff791

Browse files
Press enter prompt (#88)
2 parents ddfa75d + 351913b commit 88ff791

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.changeset/twelve-frogs-behave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eth-tech-tree": patch
3+
---
4+
5+
Fixed a small bug when showing tree history, Also removed the (Y/n) that showed when prompted with "Press Enter to continue"

src/index.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { existsSync, rmSync } from "fs";
2-
import { confirm } from "@inquirer/prompts";
2+
import { confirm, input } from "@inquirer/prompts";
33
import { IUserChallenge, IChallenge, TreeNode, IUser, Actions } from "./types";
44
import chalk from "chalk";
55
import { loadChallenges, loadUserState, saveUserState } from "./utils/state-manager";
@@ -319,7 +319,7 @@ Open up the challenge in your favorite code editor and follow the instructions i
319319
} else {
320320
actions["Reset Challenge"] = async () => {
321321
this.clearView();
322-
const confirmReset = await this.pressEnterToContinue("Are you sure you want to reset this challenge? This will remove the challenge from your local machine and re-install it.", false);
322+
const confirmReset = await this.yesOrNo("Are you sure you want to reset this challenge? This will remove the challenge from your local machine and re-install it.", false);
323323
if (!confirmReset) {
324324
await this.goBack();
325325
} else {
@@ -355,9 +355,9 @@ Open up the challenge in your favorite code editor and follow the instructions i
355355
return actions;
356356
};
357357

358-
async pressEnterToContinue(customMessage?: string, defaultAnswer: boolean = true) {
358+
async yesOrNo(message: string, defaultAnswer: boolean = true) {
359359
const answer = await confirm({
360-
message: typeof customMessage === "string" ? customMessage : 'Press Enter to continue...',
360+
message,
361361
default: defaultAnswer,
362362
theme: {
363363
prefix: "",
@@ -366,6 +366,16 @@ Open up the challenge in your favorite code editor and follow the instructions i
366366
return answer;
367367
}
368368

369+
async pressEnterToContinue(customMessage?: string) {
370+
const answer = await input({
371+
message: typeof customMessage === "string" ? customMessage : 'Press Enter to continue...',
372+
theme: {
373+
prefix: "",
374+
}
375+
});
376+
return answer;
377+
}
378+
369379
private clearView(): void {
370380
process.stdout.moveCursor(0, this.getMaxViewHeight());
371381
console.clear();

0 commit comments

Comments
 (0)