From 9d808fa8f61092b67d1609f55a654f6286ded891 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Wed, 23 Jan 2019 15:08:15 +0100 Subject: [PATCH] feat: exit command line tool on unhandled Promise rejections Currently the code base is slowly switching from callback style to async/await. This means that there are more cases where there are unhandled Promise rejections, sometime they even can't easilt be prevented. The command line interface now exits just like there was a normal exception. --- src/cli/bin.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cli/bin.js b/src/cli/bin.js index f602d1c7a2..356af18d65 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -17,6 +17,12 @@ updateNotifier({ updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week }).notify() +// Exit if there were undhandled Promise rejections +process.on('unhandledRejection', (error) => { + print(error.message) + process.exit(1) +}) + const args = process.argv.slice(2) const cli = yargs