I tried to make a simple cli nodejs game, with inquirer to ask for player input - name and question answers.
I wrote the following code, which works as expected:
async function askName() {
playerName = (await inquirer.prompt({
name: 'player_name',
type: 'input',
message: 'What is your name?',
default() {
return 'Player';
},
})).player_name;
}
But this code does not work and my debugger won't go into it:
async function acceptAnswer() {
await inquirer.prompt({
name: 'player_name',
type: 'input',
message: 'What is your answer',
validate(text) {
if (/^[\u05D0-\u05EA]{5}$/.test(text)) // check if the input is a five letter word in Hebrew
return true;
console.log(chalk.red("Please try again"));
return false;
},
});
}
(I check, and chalk isn't the problem).
I run JetBrains Webstorm on windows 21H2 with nodejs 16.13.2 and npm 8.1.2 Any help appreciated!