File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,8 @@ export async function startVitest(
8787 return ctx
8888 }
8989
90- if ( process . stdin . isTTY && ctx . config . watch )
90+ if ( process . stdin . isTTY )
9191 registerConsoleShortcuts ( ctx )
92- else
93- process . on ( 'SIGINT' , ( ) => ctx . cancelCurrentRun ( 'keyboard-input' ) )
9492
9593 ctx . onServerRestart ( ( reason ) => {
9694 ctx . report ( 'onServerRestart' , reason )
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export function registerConsoleShortcuts(ctx: Vitest) {
3232 // If cancelling takes long and key is pressed multiple times, exit forcefully.
3333 if ( str === '\x03' || str === '\x1B' || ( key && key . ctrl && key . name === 'c' ) ) {
3434 if ( ! ctx . isCancelling ) {
35+ ctx . logger . logUpdate . clear ( )
36+ ctx . logger . log ( c . red ( 'Cancelling test run. Press CTRL+c again to exit forcefully.\n' ) )
37+ process . exitCode = 130
38+
3539 await ctx . cancelCurrentRun ( 'keyboard-input' )
3640 await ctx . runningPromise
3741 }
@@ -45,6 +49,10 @@ export function registerConsoleShortcuts(ctx: Vitest) {
4549 return
4650 }
4751
52+ // Other keys are for watch mode only
53+ if ( ! ctx . config . watch )
54+ return
55+
4856 const name = key ?. name
4957
5058 if ( ctx . runningPromise ) {
You can’t perform that action at this time.
0 commit comments