From cafc895fd47186f7e7ba1cf54417c4091de756d8 Mon Sep 17 00:00:00 2001 From: yoho Date: Sun, 4 Dec 2022 00:56:10 +0800 Subject: [PATCH 1/2] feat: suspend process --- packages/vitest/src/node/stdin.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vitest/src/node/stdin.ts b/packages/vitest/src/node/stdin.ts index 667157fe76da..0dd5c2aaa111 100644 --- a/packages/vitest/src/node/stdin.ts +++ b/packages/vitest/src/node/stdin.ts @@ -30,6 +30,12 @@ export function registerConsoleShortcuts(ctx: Vitest) { if (str === '\x03' || str === '\x1B' || (key && key.ctrl && key.name === 'c')) return ctx.exit(true) + if (key && key.ctrl && key.name === 'z') { + process.kill(process.ppid, 'SIGTSTP') + process.kill(process.pid, 'SIGTSTP') + return + } + // is running, ignore keypress if (ctx.runningPromise) return From 98a1f2d107fbc154625bbf13930925b45f98beed Mon Sep 17 00:00:00 2001 From: yoho Date: Sun, 4 Dec 2022 08:55:40 +0800 Subject: [PATCH 2/2] chore: update --- packages/vitest/src/node/stdin.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vitest/src/node/stdin.ts b/packages/vitest/src/node/stdin.ts index 0dd5c2aaa111..fce2a739e0bb 100644 --- a/packages/vitest/src/node/stdin.ts +++ b/packages/vitest/src/node/stdin.ts @@ -1,7 +1,7 @@ import readline from 'readline' import c from 'picocolors' import prompt from 'prompts' -import { stdout } from '../utils' +import { isWindows, stdout } from '../utils' import type { Vitest } from './core' const keys = [ @@ -30,7 +30,8 @@ export function registerConsoleShortcuts(ctx: Vitest) { if (str === '\x03' || str === '\x1B' || (key && key.ctrl && key.name === 'c')) return ctx.exit(true) - if (key && key.ctrl && key.name === 'z') { + // window not support suspend + if (!isWindows && key && key.ctrl && key.name === 'z') { process.kill(process.ppid, 'SIGTSTP') process.kill(process.pid, 'SIGTSTP') return