From b8ee821ca1f632f20a93073454a67a218cb9bcf0 Mon Sep 17 00:00:00 2001 From: yoho Date: Mon, 5 Dec 2022 20:18:00 +0800 Subject: [PATCH] feat: suspend process (#2422) * feat: suspend process * chore: update --- packages/vitest/src/node/stdin.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/stdin.ts b/packages/vitest/src/node/stdin.ts index 667157fe76da..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,6 +30,13 @@ export function registerConsoleShortcuts(ctx: Vitest) { if (str === '\x03' || str === '\x1B' || (key && key.ctrl && key.name === 'c')) return ctx.exit(true) + // window not support suspend + if (!isWindows && 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