File tree 2 files changed +9
-3
lines changed
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(
87
87
return ctx
88
88
}
89
89
90
- if ( process . stdin . isTTY && ctx . config . watch )
90
+ if ( process . stdin . isTTY )
91
91
registerConsoleShortcuts ( ctx )
92
- else
93
- process . on ( 'SIGINT' , ( ) => ctx . cancelCurrentRun ( 'keyboard-input' ) )
94
92
95
93
ctx . onServerRestart ( ( reason ) => {
96
94
ctx . report ( 'onServerRestart' , reason )
Original file line number Diff line number Diff line change @@ -32,6 +32,10 @@ export function registerConsoleShortcuts(ctx: Vitest) {
32
32
// If cancelling takes long and key is pressed multiple times, exit forcefully.
33
33
if ( str === '\x03' || str === '\x1B' || ( key && key . ctrl && key . name === 'c' ) ) {
34
34
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
+
35
39
await ctx . cancelCurrentRun ( 'keyboard-input' )
36
40
await ctx . runningPromise
37
41
}
@@ -45,6 +49,10 @@ export function registerConsoleShortcuts(ctx: Vitest) {
45
49
return
46
50
}
47
51
52
+ // Other keys are for watch mode only
53
+ if ( ! ctx . config . watch )
54
+ return
55
+
48
56
const name = key ?. name
49
57
50
58
if ( ctx . runningPromise ) {
You can’t perform that action at this time.
0 commit comments