@@ -646,28 +646,22 @@ export const spinner = () => {
646646 unblock ( ) ;
647647 } ;
648648
649- const handleCancel = ( ) => {
649+ const handleExit = ( code : number ) => {
650650 if ( isSpinnerActive ) {
651- stop ( ' Canceled', 1 ) ;
651+ stop ( code > 1 ? 'Something went wrong' : ' Canceled', code ) ;
652652 }
653653 } ;
654654
655- const handleError = ( ) => {
656- if ( isSpinnerActive ) {
657- stop ( 'Something went wrong' , 2 ) ;
658- }
659- } ;
660-
661- // Trigger on code exception
662- process . on ( 'uncaughtException' , handleError ) ;
663- // Trigger on promise rejection
664- process . on ( 'unhandledRejection' , handleError ) ;
655+ // Trigger on uncaught code exception
656+ process . on ( 'uncaughtException' , ( ) => handleExit ( 2 ) ) ;
657+ // Trigger on unhandled promise rejection
658+ process . on ( 'unhandledRejection' , ( ) => handleExit ( 2 ) ) ;
665659 // Trigger on Ctrl + C -> multi platform
666- process . on ( 'SIGINT' , handleCancel ) ;
660+ process . on ( 'SIGINT' , ( ) => handleExit ( 1 ) ) ;
667661 // Trigger on kill process
668- process . on ( 'SIGTERM' , handleCancel ) ;
662+ process . on ( 'SIGTERM' , ( ) => handleExit ( 1 ) ) ;
669663 // Trigger on system shutdown
670- process . on ( 'exit' , handleCancel ) ;
664+ process . on ( 'exit' , handleExit ) ;
671665
672666 return {
673667 start,
0 commit comments