@@ -642,22 +642,17 @@ export const spinner = () => {
642642 unblock ( ) ;
643643 } ;
644644
645- const handleExit = ( code : number ) => {
646- if ( isSpinnerActive ) {
647- stop ( code > 1 ? 'Something went wrong' : 'Canceled' , code ) ;
648- }
645+ const handleExit = ( code : number , error ?: unknown ) => {
646+ const message = code > 1 ? 'Something went wrong' : 'Canceled' ;
647+ if ( isSpinnerActive ) stop ( message , code ) ;
648+ if ( error ) console . error ( error ) ;
649649 } ;
650650
651- /**
652- * Signal Events: https://nodejs.org/api/process.html#signal-events
653- * `uncaughtException`: Trigger on uncaught code exception
654- * `unhandledRejection`: Trigger on unhandled promise rejection
655- * `SIGINT`: Trigger on Ctrl + C. PS: it will not trigger while terminal raw mode is enabled
656- * `SIGTERM`: Trigger on kill process
657- * `exit`: Trigger on exit
658- */
659- process . on ( 'uncaughtException' , ( ) => handleExit ( 2 ) ) ;
660- process . on ( 'unhandledRejection' , ( ) => handleExit ( 2 ) ) ;
651+ // Reference: https://nodejs.org/api/process.html#event-uncaughtexception
652+ process . on ( 'uncaughtException' , ( error ) => handleExit ( 2 , error ) ) ;
653+ // Reference: https://nodejs.org/api/process.html#event-unhandledrejection
654+ process . on ( 'unhandledRejection' , ( error ) => handleExit ( 2 , error ) ) ;
655+ // Reference Signal Events: https://nodejs.org/api/process.html#signal-events
661656 process . on ( 'SIGINT' , ( ) => handleExit ( 1 ) ) ;
662657 process . on ( 'SIGTERM' , ( ) => handleExit ( 1 ) ) ;
663658 process . on ( 'exit' , handleExit ) ;
0 commit comments