Catch nick promise failure

This commit is contained in:
Franck Royer 2021-04-20 10:07:14 +10:00
parent 4542e01f0e
commit 0241d9edf3
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 11 additions and 6 deletions

View File

@ -31,12 +31,17 @@ const ChatContentTopic = 'dingpu';
output: process.stdout,
});
let nick = 'js-waku';
try {
const question = util.promisify(rl.question).bind(rl);
// Looks like wrong type definition of promisify is picked.
// May be related to https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20497
const nick = ((await question(
nick = ((await question(
'Please choose a nickname: '
)) as unknown) as string;
} catch (e) {
console.log('Using default nick.');
}
console.log(`Hi, ${nick}!`);