Skip to content

Commit

Permalink
feat: suspend process (#2422)
Browse files Browse the repository at this point in the history
* feat: suspend process

* chore: update
  • Loading branch information
poyoho committed Dec 5, 2022
1 parent 1155409 commit b8ee821
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion 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 = [
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b8ee821

Please sign in to comment.