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