Skip to content

Commit

Permalink
Asynchronously wait for the browser to close before exiting the process
Browse files Browse the repository at this point in the history
  • Loading branch information
jsarem authored and astefanutti committed Feb 29, 2024
1 parent 65153a2 commit 372c805
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions decktape.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,14 @@ process.on('unhandledRejection', error => {
.then(async context => {
await writePdf(options.filename, pdf);
console.log(chalk.green(`\nPrinted ${chalk.bold('%s')} slides`), context.exportedSlides);
browser.close();
// Wait for the browser to close before exiting the process
await browser.close();
process.exit();
}))
.catch(error => {
.catch(async error => {
console.log(chalk.red('\n%s'), error);
browser.close();
// Wait for the browser to close before exiting the process
await browser.close();
process.exit(1);
});
})();
Expand Down

0 comments on commit 372c805

Please sign in to comment.