Skip to content

Commit

Permalink
HYP-2438: modus new should default to YES and use Y/n instead of y/n
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Oct 23, 2024
1 parent 7da3e1b commit 5634d7d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cli/src/commands/new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class NewCommand extends Command {
this.logError("A template is required.");
this.exit(1);
}
if (!flags.force && !(await this.confirmAction("Continue? [y/n]"))) {
if (!flags.force && !(await this.confirmAction("Continue? [Y/n]"))) {
this.log(chalk.dim("Aborted."));
this.exit(1);
}
Expand Down Expand Up @@ -316,11 +316,18 @@ export default class NewCommand extends Command {
this.log(chalk.red(" ERROR ") + chalk.dim(": " + message));
}

private async confirmAction(message: string): Promise<boolean> {
private async confirmAction(message: string, defaultToContinue = true): Promise<boolean> {
this.log(message);
const cont = ((await ask(chalk.dim(" -> "))) || "n").toLowerCase().trim();
const input = await ask(chalk.dim(" -> "));

if (input === "") {
clearLine(2);
return defaultToContinue;
}

const shouldContinue = (input || "n").toLowerCase().trim();
clearLine(2);
return cont === "yes" || cont === "y";
return shouldContinue === "yes" || shouldContinue === "y";
}
}

Expand Down

0 comments on commit 5634d7d

Please sign in to comment.