Skip to content

Commit

Permalink
fix: createVitest need also register console shortcuts (#3561)
Browse files Browse the repository at this point in the history
  • Loading branch information
deot committed Jun 13, 2023
1 parent 158c4bb commit 2adcf98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions packages/vitest/src/node/cli-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getEnvPackageName } from '../integrations/env'
import type { UserConfig, Vitest, VitestRunMode } from '../types'
import { ensurePackageInstalled } from './pkg'
import { createVitest } from './create'
import { registerConsoleShortcuts } from './stdin'

export interface CliOptions extends UserConfig {
/**
Expand Down Expand Up @@ -87,11 +86,6 @@ export async function startVitest(
return ctx
}

if (process.stdin.isTTY && ctx.config.watch)
registerConsoleShortcuts(ctx)
else
process.on('SIGINT', () => ctx.cancelCurrentRun('keyboard-input'))

ctx.onServerRestart((reason) => {
ctx.report('onServerRestart', reason)

Expand Down
6 changes: 6 additions & 0 deletions packages/vitest/src/node/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { UserConfig, VitestRunMode } from '../types'
import { configFiles } from '../constants'
import { Vitest } from './core'
import { VitestPlugin } from './plugins'
import { registerConsoleShortcuts } from './stdin'

export async function createVitest(mode: VitestRunMode, options: UserConfig, viteOverrides: ViteUserConfig = {}) {
const ctx = new Vitest(mode)
Expand Down Expand Up @@ -33,5 +34,10 @@ export async function createVitest(mode: VitestRunMode, options: UserConfig, vit
else
await server.pluginContainer.buildStart({})

if (process.stdin.isTTY && ctx.config.watch)
registerConsoleShortcuts(ctx)
else
process.on('SIGINT', () => ctx.cancelCurrentRun('keyboard-input'))

return ctx
}

0 comments on commit 2adcf98

Please sign in to comment.