I am trying to promisify readline like this:
const readline = require('readline');
function question(question) {
return new Promise(resolve => {
console.log('this is reached');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question(question, (answer) => {
console.log('this is never reached');
rl.close();
resolve(answer);
});
});
}
async function main() {
await question(`Enter a value': `);
}
But even though I enter a value and press enter, the promise is not resolved. What might be wrong?