@@ -6,7 +6,6 @@ import { mergeConfig } from 'vite'
66import { basename , dirname , join , normalize , relative , resolve } from 'pathe'
77import fg from 'fast-glob'
88import mm from 'micromatch'
9- import c from 'picocolors'
109import { ViteNodeRunner } from 'vite-node/client'
1110import { SnapshotManager } from '@vitest/snapshot/manager'
1211import type { CancelReason , File , TaskResultPack } from '@vitest/runner'
@@ -29,6 +28,7 @@ import { VitestCache } from './cache'
2928import { WorkspaceProject , initializeProject } from './workspace'
3029import { VitestPackageInstaller } from './packageInstaller'
3130import { BlobReporter , readBlobs } from './reporters/blob'
31+ import { FilesNotFoundError , GitNotFoundError } from './errors'
3232
3333const WATCHER_DEBOUNCE = 100
3434
@@ -492,7 +492,8 @@ export class Vitest {
492492
493493 if ( ! this . config . watch || ! ( this . config . changed || this . config . related ?. length ) ) {
494494 const exitCode = this . config . passWithNoTests ? 0 : 1
495- process . exit ( exitCode )
495+ process . exitCode = exitCode
496+ throw new FilesNotFoundError ( this . mode )
496497 }
497498 }
498499
@@ -564,8 +565,8 @@ export class Vitest {
564565 changedSince : this . config . changed ,
565566 } )
566567 if ( ! related ) {
567- this . logger . error ( c . red ( 'Could not find Git root. Have you initialized git with `git init`?\n' ) )
568- process . exit ( 1 )
568+ process . exitCode = 1
569+ throw new GitNotFoundError ( )
569570 }
570571 this . config . related = Array . from ( new Set ( related ) )
571572 }
0 commit comments